oracle题目
1. /*1、选择在部门30中员工的所有信息*/
2. select * from scott.emp where deptno = '30'
3. /*2、列出职位为(MANAGER)的员工的编号,姓名 */
4. select empno, ename from scott.emp where job = 'MANAGER'
5. /*3、找出奖金高于工资的员工*/
6. select * from scott.emp where comm > sal
7. /*4、找出每个员工奖金和工资的总和 */
8. select ename, sal + nvl(comm, 0) from scott.emp
9. /*5、找出部门10中的经理(MANAGER)和部门20中的普通员工(CLERK) */
10. select *
11. from scott.emp
12. where deptno = '10'
13. and job = 'MANAGER'
14. union
15. select *
16. from scott.emp
17. where job = 'CLERK'
18. and deptno = '20'
19. /*6、找出部门10中既不是经理也不是普通员工,而且工资大于等于2000的员工 */
20. select *
21. from scott.emp
22. where job != 'MANAGER'
23. and job != 'CLERK'
24. and sal > 2000
25. /*7、找出有奖金的员工的不同工作 */
26. select distinct(job) from scott.emp where comm is not null
27. /*8、找出没有奖金或者奖金低于500的员工*/
28. select *
29. from scott.emp
30. where comm is not null
31. and comm > 500
32. /*9、显示雇员姓名,根据其服务年限,将最老的雇员排在最前面 */
33. select ename
34. from scott.emp
35. order by (months_between(sysdate, hiredate) / 12) desc
36.
37. select ename,hiredate from scott.emp order by hiredate
38. /*10、找出每个月倒数第三天受雇的员工*/
39. select * from scott.emp where hiredate = last_day(hiredate) - 2
40. /*11、分别用case和decode函数列出员工所在的部门,deptno=10显示'部门10',
41. deptno=20显示'部门20'
42. deptno=30显示'部门30'
43. deptno=40显示'部门40'
44. 否则为'其他部门'*/
45. select ename,
46. case deptno
47. when 10 then
48. '部门10'
49. when 20 then
50. '部门20'
51. when 30 then
52. '部门30'
53. when 40 then
54. '部门40'
55. else
56. '其他部门'
57. end 工资情况
58. from scott.emp
59.
60. select ename,
61. decode(deptno,
62. 10,
63. &nb