我有这样的SQL查询:
SELECT E.snum
FROM Enrolled E
GROUP BY E.snum
HAVING COUNT (*) >= ALL (SELECT COUNT(*)
FROM enrolled E2
GROUP BY E2.snum)
但这会产生一个错误:
您的SQL语法有误。检查手册
对应于您的MySQL服务器版本以使用正确的语法
靠近')> = ALL(从已注册的E2 GROUP BY E2.snum中选择COUNT()个)
第1行的LIMIT 0,30'
错误是什么意思?为什么不允许我使用ALL运算符?
最佳答案
尝试这个
SELECT E.snum, COUNT(E.snum)
FROM Enrolled E
GROUP BY E.snum
HAVING COUNT (E.snum) >= ALL (SELECT COUNT(*)
FROM enrolled E2
GROUP BY E2.snum)