sql 使用group by,having,count函数查询表中某字段相同内容的数据

Posted Johnny

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 使用group by,having,count函数查询表中某字段相同内容的数据相关的知识,希望对你有一定的参考价值。

方法一:

select  n_code from table1(表名) where  n_orgid is not null
                group by n_code,n_orgid
                         having count(n_orgid)>1
 

方法二

select *  from 
        (select count(n_code) asfrom table1(表名) 
                group by n_code,n_orgid) as tt
                                 where c>1;
 

 

以上是关于sql 使用group by,having,count函数查询表中某字段相同内容的数据的主要内容,如果未能解决你的问题,请参考以下文章