以下の点についてお役に立てれば幸いです
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
次の行を追加するまでは機能していました。
(select handicap from players where playerid = le_player) as handicap
これにより、Subquery returns more than 1 row
エラーが発生するようになりました。
ハンディキャップは、私のplayersテーブルに追加された新しいフィールドだったので、元のテーブルにSQLを少し追加するだけでよいと思いました。
何かご意見は?
ありがとうございます