我有一个简单的表格,上面有名字和分数。我想做的是制作一份名单及其平均分数,其平均值大于该组的平均值。
我有以下SQL
语句适用于Access但不适用于我的服务器(运行MySql
):
SELECT Person, Avg(Score) AS PersonAverage FROM TblScores GROUP BY Person HAVING (((Avg(Score))>(SELECT Avg(Score) AS AverageOfAllScores FROM TblScores;)));
服务器说语法错误但我看不到哪里。有任何想法吗?感谢
答案 0 :(得分:1)
您不需要第一个;
,因为它是一个语句终止符。
改变这个:
SELECT Person, Avg(Score) AS PersonAverage FROM TblScores GROUP BY Person HAVING (((Avg(Score))>(SELECT Avg(Score) AS AverageOfAllScores FROM TblScores;)));
用这个:
SELECT Person, Avg(Score) AS PersonAverage FROM TblScores GROUP BY Person HAVING (((Avg(Score))>(SELECT Avg(Score) AS AverageOfAllScores FROM TblScores)));