select x.*,
datediff(x.next_hd,x.hiredate) diff
from (
select e.deptno,e.ename,e.hiredate,
(select min(d.hiredate) from emp d
where d.hiredate > e.hiredate) next_hd
from emp e
where e.deptno = 10
) x;
时间: 2024-10-12 07:59:22
select x.*,
datediff(x.next_hd,x.hiredate) diff
from (
select e.deptno,e.ename,e.hiredate,
(select min(d.hiredate) from emp d
where d.hiredate > e.hiredate) next_hd
from emp e
where e.deptno = 10
) x;