需要用group by中的having子句。
1、如test表中有如下数据:
2、现要查出dept出现2次以上的dept。可用如下语句:
select dept from test group by dept having count(*) >2;
3、查询结果: