日期:2014-05-17 浏览次数:20616 次
declare @tb table(
getInfoTime datetime,
waterHeight int
)
declare @begintime datetime,@endtime datetime
select @begintime='2013-5-28 09:58:00',@endtime = '2013-5-28 10:30:00'
insert @tb
select '2013-5-28 10:00:00',3
union all select '2013-5-28 10:02:00',3
union all select '2013-5-28 10:05:00',3
union all select '2013-5-28 10:06:00',3
union all select '2013-5-28 10:09:00',3
union all select '2013-5-28 10:10:00',3
union all select '2013-5-28 10:11:00',3
union all select '2013-5-28 10:13:00',3
union all select '2013-5-28 10:15:00',3
union all select '2013-5-28 10:17:00',3
union all select '2013-5-28 10:19:00',3
union all select '2013-5-28 10:20:00',3
union all select '2013-5-28 10:25:00',3
union all select '2013-5-28 10:26:00',3
;with tb as(
select *,datediff(ss,@begintime,getInfoTime)/600 dtdiff from @tb
where getInfoTime >=@begintime and getInfoTime <=@endtime
)
select getInfoTime,waterHeight from tb a
where not exists(
select 1 from tb b
where a.dtdiff = b.dtdiff
and a.getInfoTime > b.getInfoTime
)