我试图找出这位特别球员在NBA中得分后卫的位置。我正在使用this post on stackoverflow作为指南。
我收到错误“无效使用群组功能”。
SELECT
first,
last,
team,
pos,
SUM(points) AS scoresum,
ROUND(AVG(points), 2) AS avgpoints,
(SELECT
COUNT(*)
FROM nbaboxscore AS bpnb
WHERE (bpnb.first, bpnb.last, SUM(bpnb.points)) >= (bpn.first, bpn.last, SUM(bpn.points))) AS rank
FROM nbaboxscore AS bpn
WHERE bpn.pos = 'SG'
AND bpn.date >= '2009-10-01'
AND FIRST = 'Joe'
AND LAST = 'Johnson'
GROUP BY bpn.first, bpn.last, bpn.team
ORDER BY scoresum DESC
我不确定这种方式是否可行?
答案 0 :(得分:1)
您的子查询有误,您不能在SUM
和GROUP BY
使用WHERE
,因此您必须使用HAVING
。
我让你检查:http://dev.mysql.com/doc/refman/5.0/fr/select.html