SQL语句统计个数大于一的记录

1、主要是利用Having语句进行,由于where不能与聚合函数一起使用,所以用having

SELECT MC,COUNT(MC) AS SL FROM JSB GROUP BY MC HAVING(COUNT(MC)>1)

2、SELECT MC,SL FROM (SELECT MC,COUNT(MC) AS SL FROM JSB GROUP BY MC) WHERE SL>1

posted @ 2015-01-19 10:06  静以养身 俭以养德  阅读(1472)  评论(0编辑  收藏  举报