问题: 以7月为例,北京来访数量为2151条记录,调取2151条 来访主叫号码在1月--7月之间重复2次以上的数据.这个SQL脚本怎么写.有哪位大神可以指点一下.谢谢啦
select number,count(*) from table group by number having count(*)>1
select * from table where month=7 group by numberType(主叫) having count(id)>2
SELECT [tid]
,[num]
,[name]
,[tdate],[type]
FROM [Demos].[dbo].[Test002]
GO
-- 0 主叫、1 被叫
select num,name from Test002 where tdate between '2014-01-01 00:00:00' and '2014-03-31 23:59:59.999'
and [type]=0 group by name,num having COUNT(num)>=2
select phone,count(id) coun from table1 where to_date(createdate,'mm')<=7 and type=主叫 group by phone having coun>2