是否可以对结果进行分组,然后按组中的行数进行过滤?
像这样:
SELECT * FROM mytable WHERE COUNT(*) > 1 GROUP BY name
您想使用HAVING来过滤聚合函数。
SELECT name, COUNT(*) FROM mytable GROUP BY name HAVING COUNT(*) > 1