计算前后2行的时间差

select *,datediff(ss,(select max( CreateTime) from Table1 b where b.id<a.id),a.CreateTime)
from Table1 a

Table1表有自增长字段Id

Table表的CreateTime也是随着Id而增大的

原文地址:https://www.cnblogs.com/zhshlimi/p/5198749.html