您的位置:首页 > 数据库

SQL查询--列出受雇日期早于直接上级的所有员工

2017-04-25 16:29 2211 查看
请先查看解决问题所需的数据表结构:点击跳转

问题:列出受雇日期早于直接上级的所有员工

答案:

解法一:

select a.ename from emp a where a.hiredate<(select hiredate from emp b where b.empno=a.mgr);

解法二:

select t.ename from emp t where t.mgr is not null and not exists

(select null from emp m where t.mgr=m.empno and t.hiredate>m.hiredate);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql