最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

SQL笔试题:公司员工与部门查询

来源:懂视网 责编:小采 时间:2020-11-09 13:36:44
文档

SQL笔试题:公司员工与部门查询

SQL笔试题:公司员工与部门查询:建表: DEPARTMENTS:DEPARTMENT_ID(primary key),DEPARTMENT_NAME,LOCATIONEMPLOYEES:EMPLOYEE_ID(primary key),EMPLOYEE_NAME,EMPLOYEE_JOB,MANAGER,SALARY,DEPARTMENT_ID 列出EMPLOYEES表中各部门的部门号
推荐度:
导读SQL笔试题:公司员工与部门查询:建表: DEPARTMENTS:DEPARTMENT_ID(primary key),DEPARTMENT_NAME,LOCATIONEMPLOYEES:EMPLOYEE_ID(primary key),EMPLOYEE_NAME,EMPLOYEE_JOB,MANAGER,SALARY,DEPARTMENT_ID 列出EMPLOYEES表中各部门的部门号

建表: DEPARTMENTS:DEPARTMENT_ID(primary key),DEPARTMENT_NAME,LOCATIONEMPLOYEES:EMPLOYEE_ID(primary key),EMPLOYEE_NAME,EMPLOYEE_JOB,MANAGER,SALARY,DEPARTMENT_ID 列出EMPLOYEES表中各部门的部门号,最高工资,最低工资 select max(SALARY) as 最高

建表:

DEPARTMENTS:
DEPARTMENT_ID(primary key),
DEPARTMENT_NAME,
LOCATION
EMPLOYEES:
EMPLOYEE_ID(primary key),
EMPLOYEE_NAME,
EMPLOYEE_JOB,
MANAGER,
SALARY,
DEPARTMENT_ID
  1. 列出EMPLOYEES表中各部门的部门号,最高工资,最低工资
  2. select max(SALARY) as 最高工资,min(SALARY) as 最低工资,DEPARTMENT_ID from EMPLOYEES group by DEPARTMENT_ID;
    
  3. 列出EMPLOYEES表中各部门EMPLOYEE_JOB为'CLERK'的员工的最低工资,最高工资
  4. select max(SALARY) as 最高工资,min(SALARY) as 最低工资,DEPARTMENT_ID as 部门号 from EMPLOYEES where EMPLOYEE_JOB = 'CLERK' group by DEPARTMENT_ID;
    
  5. 对于EMPLOYEES中最低工资小于1000的部门,列出EMPLOYEE_JOB为'CLERK'的员工的部门号,最低工资,最高工资
  6. select max(SALARY) as 最高工资,min(SALARY) as 最低工资,DEPARTMENT_ID as 部门号 from EMPLOYEES as b
    where EMPLOYEE_JOB ='CLERK' and 1000>(select min(SALARY) from EMPLOYEES as a where a.DEPARTMENT_ID = b.DEPARTMENT_ID) group by b.DEPARTMENT_ID
    
  7. 根据部门号由高而低,工资有低而高列出每个员工的姓名,部门号,工资
  8. select DEPARTMENT_ID as 部门号,EMPLOYEE_NAME as 姓名,SALARY as 工资 from EMPLOYEES order by DEPARTMENT_ID desc,SALARY asc
    
  9. 写出对上题的另一解决方法
  10. 还没想到,如果你又答案,请联系www.nowamagic.net,我的联系方式在网站首页。
    
  11. 列出'张三'所在部门中每个员工的姓名与部门号
  12. select EMPLOYEE_NAME,DEPARTMENT_ID from EMPLOYEES where DEPARTMENT_ID = (select DEPARTMENT_ID from EMPLOYEES where EMPLOYEE_NAME = '张三')
    
  13. 列出每个员工的姓名,工作,部门号,部门名
  14. select EMPLOYEE_NAME,EMPLOYEE_JOB,EMPLOYEES.DEPARTMENT_ID,DEPARTMENTS.DEPARTMENT_NAME from EMPLOYEES,DEPARTMENTS where EMPLOYEES.DEPARTMENT_ID = DEPARTMENTS.DEPARTMENT_ID
    
  15. 列出EMPLOYEES中工作为'CLERK'的员工的姓名,工作,部门号,部门名
  16. select EMPLOYEE_NAME,EMPLOYEE_JOB,DEPARTMENTS.DEPARTMENT_ID,DEPARTMENT_NAME from EMPLOYEES,DEPARTMENTS where DEPARTMENTS.DEPARTMENT_ID = EMPLOYEES.DEPARTMENT_ID and DEPARTMENT_JOB = 'CLERK'
    
  17. 对于EMPLOYEES中有管理者的员工,列出姓名,管理者姓名(管理者外键为MANAGER)
  18. select a.EMPLOYEE_NAME as 姓名,b.EMPLOYEE_NAME as 管理者 from EMPLOYEES as a,EMPLOYEES as b where a.MANAGER is not null and a.MANAGER = b.EMPLOYEE_ID
    
  19. 对于DEPARTMENTS表中,列出所有部门名,部门号,同时列出各部门工作为'CLERK'的员工名与工作
  20. select DEPARTMENT_NAME as 部门名,DEPARTMENTS.DEPARTMENT_ID as 部门号,EMPLOYEE_NAME as 员工名,EMPLOYEE_JOB as 工作 from DEPARTMENTS,EMPLOYEES 
    where DEPARTMENTS.DEPARTMENT_ID *= EMPLOYEES.DEPARTMENT_ID and EMPLOYEE_JOB = 'CLERK'
    
  21. 对于工资高于本部门平均水平的员工,列出部门号,姓名,工资,按部门号排序
  22. select a.DEPARTMENT_ID as 部门号,a.EMPLOYEE_NAME as 姓名,a.SALARY as 工资 from EMPLOYEES as a
    where a.SALARY>(select avg(SALARY) from EMPLOYEES as b where a.DEPARTMENT_ID = b.DEPARTMENT_ID) order by a.DEPARTMENT_ID
    
  23. 对于EMPLOYEES,列出各个部门中平均工资高于本部门平均水平的员工数和部门号,按部门号排序
  24. select count(a.SALARY) as 员工数,a.DEPARTMENT_ID as 部门号 from EMPLOYEES as a
    where a.SALARY>(select avg(SALARY) from EMPLOYEES as b where a.DEPARTMENT_ID = b.DEPARTMENT_ID) group by a.DEPARTMENT_ID order by a.DEPARTMENT_ID
    
  25. 对于EMPLOYEES中工资高于本部门平均水平,人数多与1人的,列出部门号,人数,按部门号排序
  26. select count(a.EMPLOYEE_ID) as 员工数,a.DEPARTMENT_ID as 部门号,avg(SALARY) as 平均工资 from EMPLOYEES as a
    where (select count(c.EMPLOYEE_ID) from EMPLOYEES as c where c.DEPARTMENT_ID = a.DEPARTMENT_ID and c.SALARY>(select avg(SALARY) from EMPLOYEES as b where c.DEPARTMENT_ID = b.DEPARTMENT_ID))>1
    group by a.DEPARTMENT_ID order by a.DEPARTMENT_ID
    
  27. 对于EMPLOYEES中低于自己工资至少5人的员工,列出其部门号,姓名,工资,以及工资少于自己的人数
  28. select a.DEPARTMENT_ID,a.EMPLOYEE_NAME,a.SALARY,(select count(b.EMPLOYEE_NAME) from EMPLOYEES as b where b.SALARY < a.SALARY) as 人数 from EMPLOYEES as a
    where (select count(b.EMPLOYEE_NAME) from EMPLOYEES as b where b.SALARY5
    

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

SQL笔试题:公司员工与部门查询

SQL笔试题:公司员工与部门查询:建表: DEPARTMENTS:DEPARTMENT_ID(primary key),DEPARTMENT_NAME,LOCATIONEMPLOYEES:EMPLOYEE_ID(primary key),EMPLOYEE_NAME,EMPLOYEE_JOB,MANAGER,SALARY,DEPARTMENT_ID 列出EMPLOYEES表中各部门的部门号
推荐度:
标签: 查询 公司 员工
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top