关键点在于如何获得下一条日期。
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
原文:https://www.cnblogs.com/aoximin/p/12639694.html