我将不胜感激以下方面的帮助
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
错误。
Handicap 是添加到我的玩家表中的一个新字段,所以我认为我可以将那一点 sql 添加到我的原始字段中。
有什么想法吗?
谢谢dg