62,263
社区成员
发帖
与我相关
我的任务
分享select * from <table> a where
(select count(*) from <table> b where a.NAME=b.NAME and DateDiff(month,DTIME,getdate()) > 5) >= 2
and DateDiff(month,DTIME,getdate()) > 5
order by NAME, DTIME<table>要换成你的表名,如果是时间相差是天,把month改成day
select * from [表名] where datediff(day,DTIme,getdate())>5 and [Name] in (select [Name] from [表名] group by [Name] having count([Name])>2)
select * from Table where DateDiff(days,DateTime,getday()) > 5 and (select count(*) from Table where DateDiff(days,DateTime,getday()) > 5)>2
declare i as int
select i = count(*) from Table where DateDiff(days,DateTime,getday()) > 5
if i > 2
select * from Table where DateDiff(days,DateTime,getday()) > 5