select s.grade "工资等级",count(*)"人数"from emp e,salgrade s
where sal between s.losal and s.hisal
groupby s.grade
-3 List the names of all employees and their immediate superiors
-- nvl(null,0) 如果为null 返回0select e1.ename,nvl(e2.ename,'没有上级')from emp e1,emp e2
where e1.mgr=e2.empno(+)
-4 List the numbers, names, and department names of all employees whose employment date is earlier than their immediate superiors
select e.empno, e.ename, d.dname from emp e,emp m ,dept d
where e.hiredate < m.hiredate
and
e.mgr = m.empno
and
e.deptno = d.deptno
--5 List the department name and the employee information of these departments, and also list those departments without employees.
Use the right link because the department name to be displayed (and those departments without employees are listed at the same time) are all the departments in reality
select d.dname"部门名称", e.*from emp e,dept d
where e.deptno(+)=d.deptno
–6 List all departments with at least one employee