Oracle经典练习/*1、选择在部门30中员工的所有信息*/select*fromscott.empwheredeptno='30'/*2、列出职位为(MANAGER)的员工的编号,姓名*/selectempno,enamefromscott.empwherejob='MANAGER'/*3、找出奖金高于工资的员工*/select*fromscott.empwherecomm>sal/*4、找出每个员工奖金和工资的总和*/selectename,sal+nvl(comm,0)fromscott.emp/*5、找出部门10中的经理(MANAGER)和部门20中的普通员工(CLERK)*/select*fromscott.empwheredeptno='10'andjob='MANAGER'unionselect*fromscott.empwherejob='CLERK'anddeptno='20'/*6、找出部门10中既不是经理也不是普通员工,而且工资大于等于2000的员工*/select*fromscott.empwherejob!='MANAGER'andjob!='CLERK'andsal>2000/*7、找出有奖金的员工的不同工作*/selectdistinct(job)fromscott.empwherecommisnotnull/*8、找出没有奖金或者奖金低于500的员工*/select*fromscott.empwherecommisnotnullandcomm>500/*9、显示雇员姓名,根据其服务年限,将最老的雇员排在最前面*/selectenamefromscott.emporderby(months_between(sysdate,hiredate)/12)descselectename,hiredatefromscott.emporderbyhiredate/*10、找出每个月倒数第三天受雇的员工*/select*fromscott.empwherehiredate=last_day(hiredate)-2/*11、分别用case和decode函数列出员工所在的部门,deptno=10'显示部门10',deptno=20显示部门20'deptno=30显示部门30'deptno=40显示部门40'否则为其他部门'*/selectename,casedeptnowhen10then部门10'when20then部门20'when30then部门30'when40then部门40'else其他部门end工资情况fromscott.empselectename,decode(deptno,10,部门10',20,部门20',30,部门30',40,部门40',其他部门')工资情况fromscott.emp/*12、分组统计各部门下工资>500的员工的平均工资*/selectavg(sal)fromscott.empwheresal>500groupbydeptno/*13、统计各部门下平均工资大于500的部门*/selectdeptnofromscott.empgroupbydeptnohavingavg(sal)>500/*14、算出部门30中得到最多奖金的员工奖金*/selectmax(comm)fromscott.empwheredeptno=30/*15、算出部门30中得到最多奖金的员工姓名*/selectenamefromscott.empwheredeptno=30andcomm=(selectmax(comm)fromscott.empwheredeptno=30)/*16、算出每个职位的员工数和最低工资*/selectcount(ename),min(sal),jobfromscott.empgroupbyjob/*17、列出员工表中每个部门的员工数,和部门no*/selectcou...