34,575
社区成员
发帖
与我相关
我的任务
分享
with m as (
select '6:05:18' a union all
select '6:05:28' union all
select '6:05:38' union all
select '6:05:48'
)
-- prev 是上一个行的时间 ,你再减一下就可以了
select a , (select top 1 a from m n where m.a > n.a order by a desc) prev
from m
a prev
------- -------
6:05:18 NULL
6:05:28 6:05:18
6:05:38 6:05:28
6:05:48 6:05:38
(4 行受影响)