本文介绍了按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

这篇关于按COUNT(*)过滤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 14:16