我想編寫一個查詢返回小鎮,並從每個小鎮選手的數量大於5爲什麼不能在where子句中使用Count()運算符?我如何解決這個問題?
我的查詢選手的數量現在看起來是這樣的:
select hometown, count(hometown) from marathon2016 where count(hometown) > 5 group by hometown order by count(hometown) desc;
但sqlite3的這一回應:
Error: misuse of aggregate: count()
什麼我做錯了什麼,爲什麼不能我使用COUNT()在這裏,我就改用什麼。
那麼,有沒有辦法只能獲得其中只有5人以上的城鎮中列出的結果? –
@BryceEdwards我誤解了你的問題。更新了我的答案。 –