是否可以对结果进行分组,然后按组中的行数进行过滤?
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
这篇关于按 COUNT(*) 过滤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!