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

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

乌龟才背着房子过一辈子
原文地址:https://www.cnblogs.com/Yellowshorts/p/2783995.html