计算当前记录和下一条记录之间的日期差
关键点在于如何获得下一条日期。
mysql 和 sql server
select x.*,DATEDIFF(day,x.HIREDATE,x.next_hd) diff
from(
select e.DEPTNO,e.ENAME,e.HIREDATE,(select MIN(HIREDATE) from emp d where d.HIREDATE>e.HIREDATE) next_hd
from EMP e
where e.DEPTNO=10
) x