赞
踩
数据表:
dept:
deptno(primary key), dname, loc
emp:
empno(primary key), ename, job, mgr(references emp(empno)), sal,
deptno(references dept(deptno))
1 列出emp表中各部门的部门号,最高工资,最低工资
select max(sal) as 最高工资,min(sal) as 最低工资,deptno from emp group by deptno;
2 列出emp表中各部门job 含’REP’的员工的部门号,最低工资,最高工资
select max(sal) as 最高工资,min(sal) as 最低工资,deptno as 部门号 from emp where job like '%REP%' group by deptno;
3 对于emp中最低工资小于7000的部门中job为'SA_REP'的员工的部门号,最低工资,最高工资
select max(sal) as 最高工资,min(sal) as 最低工资,deptno as 部门号 from emp b
where job='SA_REP' and 7000>(select min(sal) from emp a where a
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。