按 COUNT(*) 过滤?
是否可以对结果进行分组,然后按组中的行数进行过滤?
Is it possible to group results and then filter by how many rows are in the group?
像这样:
SELECT * FROM mytable WHERE COUNT(*) > 1 GROUP BY name
推荐答案
您想使用 HAVING 对聚合函数进行过滤.
You want to use HAVING to filter on the aggregate function.
SELECT name, COUNT(*)
FROM mytable
GROUP BY name
HAVING COUNT(*) > 1
相关文章