34,590
社区成员
发帖
与我相关
我的任务
分享
找出数据库中内容一样的手机号码,以及时间
还有数量
Select Mobile, Content, Year(theDate), Month(theDate), Nums = Count(*)
From 表
Group By Mobile, Content, Year(theDate), Month(theDate)
Having Count(*) > 1
或者用这个笨办法
select * from tb where cast(content as varchar) + ','+ convert(varchar(7),日期,120) in (select cast(content as varchar) + ','+ convert(varchar(7),日期,120) from tb group by cast(content as varchar) + ','+ convert(varchar(7),日期,120) having count(*) > 1)
--上面错了还要考虑日期.
select * from tb where exists(select content,convert(varchar(7),日期,120) from tb group by content,convert(varchar(7),日期,120) having count(*) > 1)
select * from tb where content in (select content from tb group by content having count(*) > 1)