我试图执行以下命令:
SELECT name,sum(mark)
FROM students
group by name order by mark
但我收到了错误。
专栏" students.mark"在ORDER BY子句中无效,因为它不包含在聚合函数或GROUP BY子句中。
我无法理解错误。
答案 0 :(得分:3)
尝试使用此
SELECT name,sum(mark) FROM students group by name order by sum(mark)
希望这有帮助
答案 1 :(得分:3)
将SUM
汇总移至Order by
SELECT name,sum(mark) FROM students group by name order by sum(mark)
或使用别名
SELECT name,sum(mark) as Mark FROM students group by name order by mark
答案 2 :(得分:0)
这应该对你有用,
SELECT name,sum(mark) FROM students group by name order by sum(mark)
您需要按顺序指定sum
聚合