22,209
社区成员
发帖
与我相关
我的任务
分享
declare @test table(data int,dt varchar(20))
declare @tmp table(sn varchar(2))
declare @i int
set @i=1
while @i<60
begin
insert into @tmp values(cast(right(100+@i,2) as varchar(2)))
set @i=@i+1
end
set @i=1
while @i<60
begin
if @i<>5 and @i<>16
insert into @test values(@i*@i,'2012-08-25 14:'+cast(right(100+@i,2) as varchar(2)))
set @i=@i+1
end
select * from
(
select a.sn sn1,b.sn sn2,b.data,b.dt from @tmp a
left join (select right(dt,2) sn,* from @test) b
on a.sn=b.sn
)t
where sn2 is null
--where datediff(hh,b.dt+'.000',getdate())=1