数据库部分我都忘光了,回来后查手册和找同学帮忙,终于做出来了。
#第1题答案
SELECT deptno, max(sal), min(sal)
FROM emp
GROUP BY deptno;
#第2题答案
ALTER TABLE emp ADD remark VARCHAR(64);
#第3题答案
select e.deptno,d.dname,e.ename,e.sal
from emp AS e,dept AS d
where e.deptno=d.deptno
and
(sal>(select avg(sal) from emp group by deptno having deptno =e.deptno));
#第4题答案
SELECT emp.deptno,dname,mgr,AVG(sal) AS mean
FROM emp,dept
WHERE emp.deptno=dept.deptno
GROUP BY deptno,mgr
ORDER BY mean DESC;
#第5题答案
select e.deptno,e.ename,e.sal, (select count(*) from emp where sal<e.sal) from emp e
where (select count(*) from emp where sal<e.sal)>5;
其中第3题和第5题是王芳做出来的。
来源:oschina
链接:https://my.oschina.net/u/923087/blog/279273