帮忙写个SQL脚本求帮忙

问题: 以7月为例,北京来访数量为2151条记录,调取2151条 来访主叫号码在1月--7月之间重复2次以上的数据.这个SQL脚本怎么写.有哪位大神可以指点一下.谢谢啦

4个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!