Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:42:51+00:00 2026-06-17T06:42:51+00:00

I would appreciate some help with the following SELECT distinct playerid as le_player, (select

  • 0

I would appreciate some help with the following

SELECT distinct playerid as le_player, 
    (select sum(score) from playerresults where playerid = le_player) as wins, 
    (select handicap from players where playerid = le_player) as handicap, playername, 
    (select count(playerid)*3 from playerresults where playerid = le_player)as totalgames, 
    (select count(playerid)*3 from playerresults where playerid = le_player) - (select sum(score) from playerresults where playerid = le_player)as lost, 
    round((select sum(score) from playerresults where playerid = le_player) / (select count(playerid)*3 from playerresults where playerid = le_player) * 100,2) as percent, 
    teams.team_name 
FROM playerresults 
    INNER JOIN teams on (select players.team_id from players where players.id = playerid) = teams.id 
WHERE playerresults.season = 2012 AND playerresults.league = 4 
ORDER BY wins desc,totalgames asc

It was working until I added the following line:

(select handicap from players where playerid = le_player) as handicap

This now produces a Subquery returns more than 1 row error.

Handicap was a new field added to my players table so I thought I could just add that bit of sql to my original.

Any thoughts?

Thanks
dg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:42:53+00:00Added an answer on June 17, 2026 at 6:42 am

    You might want to consider using joins with the tables instead of all of the correlated subqueries:

    SELECT playerid as le_player, 
        sum(pr.score) as wins,
        p.handicap,
        pr.playername, 
        count(pr.playerid)*3 as totalgames, 
        count(pr.playerid)*3 - sum(pr.score) as lost, 
        round(sum(pr.score) / (count(pr.playerid)*3) * 100,2) as percent, 
        t.team_name 
    from playerresults pr
    left join players p
        on pr.playerid = p.id
    left join teams t
        on p.team_id = teams.id 
    where pr.season = 2012 
        AND pr.league = 4 
    group by pr.playerid
    ORDER BY wins desc, totalgames asc;
    

    Or even something like this:

    SELECT pr.playerid as le_player, 
        Score as wins,
        p.handicap,
        pr.playername, 
        CountPlayerId*3 as totalgames, 
        CountPlayerId*3 - Score as lost, 
        round(Score / (CountPlayerId*3) * 100,2) as percent, 
        t.team_name 
    from
    (
        select playerid,
            sum(pr.score) Score,
            count(pr.playerid) CountPlayerId
        from playerresults
        WHERE season = 2012 
           AND league = 4 
        group by playerid
    ) pr
    left join players p
        on pr.playerid = p.id
    left join teams t
        on p.team_id = teams.id 
    where pr.season = 2012 
        AND pr.league = 4 
    ORDER BY wins desc, totalgames asc;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to jQuery and would really appreciate some help with the following:
I would appreciate some help with something I working on and have not done
I would appreciate some help with an UPDATE statement. I want to update tblOrderHead
I would appreciate some help on creating the proper SQL to retrieve only one
I have a problem finding references to this subject and would appreciate some help.
I'm pretty new to Python programming and would appreciate some help to a problem
I'm a newbie in Spring Batch, and I would appreciate some help to resolve
I would really appreciate it if some of you could help optimize my tables,
I am experiencing some strange behavior with OSQL, and would appreciate any help. I
Would really appreciate some help with a search angine I'm trying to make for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.