我希望按顺序显示数量和职业。我可以做的很好,但是当我在ORDER BY语句中添加第二列时不起作用。

SELECT CONCAT("There are a total of ", COUNT(occupation), " ", occupation, "s.")
FROM occupations
GROUP BY occupation
ORDER BY COUNT(occupation) ASC, occupation ASC;


结果如下:

There are a total of 3 Doctors.
There are a total of 4 Actors.
There are a total of 4 Singers.
There are a total of 7 Professors.


我尝试反转它们,还尝试指定表名(occupations.occupation)以避免任何歧义,但没有任何效果。我需要创建单独的变量吗?

最佳答案

我发布的查询是正确的-事实证明应用程序认为它是错误的,因为职业是大写的,而不是小写的

10-06 06:17