SQl Group by

分组统计 

select COUNT(*) as c,CustomerTelp from Customer
group by CustomerTelp

查询结果

想查找Num大于1的记录

目前就想到两个方法

方法1:

select * from
(
select COUNT(*) as num,CustomerTelp from Customer
group by CustomerTelp
) a
where num>2

方法2:

with a as
( select COUNT(*) as num,CustomerTelp
from Customer
group by CustomerTelp
)
select * from a where num>1

不是的那位高手有其他方法 希望能留下脚印

 

 

posted @ 2012-11-23 10:56  yellowshorts  阅读(98)  评论(0编辑  收藏  举报