MySQL数据库优化SQL

时间:2021-07-09 09:19:17
【文件属性】:

文件名称:MySQL数据库优化SQL

文件大小:879KB

文件格式:PPT

更新时间:2021-07-09 09:19:17

MySQL优化

MySQL数据库优化SQL20、查询显示每个雇员加入公司的准确时间,按××××年××月××日 时分秒显示; select ename, to_char(hiredate, 'yyyy-mm-dd hh24:mi:ss') from emp; 21、查询公司中按年份月份统计各地的录用职工数量 select d.loc, count(1) "录用人数" from emp e join dept d on e.deptno=d.deptno group by to_char(hiredate,'yyyy'), to_char(hiredate,'mm'); 22、查询列出各部门的部门名和部门经理名字 select d.deptno, d.dname, e.ename from dept d join emp e on d.deptno=e.deptno where e.job='MANAGER'; 23、查询部门平均工资最高的部门名称和最低的部门名称 select dname from dept where deptno = (select deptno from emp group by deptno having avg(sal) = (select max(avg(sal)) from emp group by deptno)); select dname from dept where deptno = (select deptno from emp group by deptno having avg(sal) = (select max(avg(sal)) from emp group by deptno)) union select dname from dept where deptno = (select deptno from emp group by deptno having avg(sal) = (select min(avg(sal)) from emp group by deptno))


网友评论