1) 選擇在部門 30 中員工的所有資訊
2) 列出職位為(MANAGER)的員工的編號,姓名
3) 找出獎金高於工資的員工
4) 找出每個員工獎金和工資的總和
5) 找出部門 10 中的經理(MANAGER)和部門 20 中的普通員工(CLERK)
6) 找出部門 10 中既不是經理也不是普通員工,而且工資大於等於 2000 的員工
7) 找出有獎金的員工的不同工作
8) 找出沒有獎金或者獎金低於 500 的員工
9) 顯示僱員姓名,根據其服務年限,將最老的僱員排在最前面
10) 分組統計各部門下工資>500 的員工的平均工資、
11) 統計各部門下平均工資大於 500 的部門
12) 算出部門 30 中得到最多獎金的員工獎金
13) 算出部門 30 中得到最多獎金的員工姓名
14) 算出每個職位的員工數和最低工資
15) 列出員工表中每個部門的員工數和部門 no
16) 得到工資大於自己部門平均工資的員工資訊
17) 分組統計每個部門下,每種職位的平均獎金(也要算沒獎金的人)和總工資(包括獎金)
代碼:
1、select*from dept where deptno = 30;
2、select empno ,ename from emp where job=’MANAGER’;
3、select ename from emp where comm>sal;
4、select ename,sal*13+nvl(comm,0)*13 “年獎金和工資總和” from emp;
5、select ename from emp where (deptno=10 and job=’MANAGER’) or (deptno=20 and job=’CLERK’);
6、select ename from emp where (deptno=10 and job not in(‘MANAGER’,’clerk’) and sal>=2000);
7、select distinct job from emp where deptno>0;
8、select ename from emp where comm<500 or comm=0;
9、select ename,hiredate from emp order by (hiredate);
10、Select avg(sal) from emp where sal>500 group by deptno ;
11、select deptno,avg(sal) from emp group by deptno having avg(sal)>500 ;
12、select max(comm) from emp where deptno = 30;
13、select ename from emp where comm = (select max(comm) from emp where deptno = 30);
14、select job,count(*),min(sal) from emp group by job;
15、select count(*),deptno from emp group by deptno;
16、select * from emp e1,(select deptno,avg(sal) as avgsal from emp group by deptno) e2
where e1.deptno=e2.deptno and e1.sal > e2.avgsal;
17、select deptno,job,avg(nvl(comm,0)),sum(sal+nvl(comm,0)) from emp group by deptno,job;