1.显示员工SMITH的姓名,部门名称,直接上级名称
SELECT e.ENAME,m.ENAME,d.DNAME
FROM emp e,emp m,dept d
WHERE e.MGR=m.EMPNO
and e.DEPTNO=d.DEPTNO
and e.ENAME='SMITH'
2.显示员工姓名,部门名称,工资,工资级别,要求工资级别大于4级。
SELECT ENAME,DNAME,SAL,GRADE
FROM emp,dept,salgrade
WHERE emp.DEPTNO=dept.DEPTNO
AND SAL BETWEEN LOSAL AND HISAL
AND GRADE>4
3.显示员工KING和FORD管理的员工姓名及其经理姓名。
select e.ename,d.dname,e.sal,s.grade
from emp e,dept d,salgrade s
where e.deptno = d.deptno
and e.sal between s.losal and s.hisal
and s.grade>4;
4.显示员工姓名,参加工作时间,经理名,参加工作时间,要求参加时间比经理早。
SELECT e.ENAME,e.HIREDATE,m.ENAME,m.HIREDATE
FROM emp e,emp m
WHERE e.MGR=m.EMPNO
AND e.HIREDATE<m.HIREDATE