标签:and ast where 查找 next har rom tno sel
select deptno,ename,hiredate,sal,
coalesce(cast(sal-next_sal as char(10)),‘N/A‘) as diff
from (
select e.deptno,
e.ename,
e.hiredate,
e.sal,
(select min(sal) from emp d
where d.deptno=e.deptno
and d.hiredate =
(select min(hiredate) from emp d
where e.deptno=d.deptno
and d.hiredate > e.hiredate)) as next_sal
from emp e
) x
order by 1;
标签:and ast where 查找 next har rom tno sel
原文地址:http://www.cnblogs.com/liang545621/p/7523320.html