3

我有一个简单的表格,上面有名字和分数。我想做的是生成一个包含平均分数的名字列表,其中他们的平均分数高于该组的平均分数。

我有以下SQL语句适用于 Access 但不适用于我的服务器(正在运行MySql):

SELECT Person, Avg(Score) AS PersonAverage FROM TblScores GROUP BY Person HAVING (((Avg(Score))>(SELECT Avg(Score) AS AverageOfAllScores FROM TblScores;))); 

服务器说语法错误,但我看不到在哪里。有任何想法吗?谢谢

4

1 回答 1

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)));
于 2013-06-12T20:00:01.177 回答