From fac1c63fa6c4bdda74cc3706e609b58e75c40c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E4=BC=9F?= <2152890632@qq.com> Date: Fri, 20 Oct 2023 00:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...12\351\242\230\347\273\203\344\271\240.md" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/12\351\242\230\347\273\203\344\271\240.md" diff --git "a/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/12\351\242\230\347\273\203\344\271\240.md" "b/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/12\351\242\230\347\273\203\344\271\240.md" new file mode 100644 index 0000000..347c2f6 --- /dev/null +++ "b/19\345\275\255\345\213\207\346\226\214/\347\254\224\350\256\260/12\351\242\230\347\273\203\344\271\240.md" @@ -0,0 +1,51 @@ +-- 1、列出最低薪金大于1500的各种工作。 +select distinct job from emp where sal<1500; +-- +-- 2、列出在部门 "销售部" 工作的员工的姓名,假定不知道销售部的部门编号。 + + +select * from emp where deptno=30; +select * from emp WHERE deptno not in (10,20); +-- 3、列出薪金高于公司平均薪金的所有员工。 +-- +select avg(sal) from emp; +select * FROM emp where sal>(select avg(sal) from emp); +-- 4、列出与"周八"从事相同工作的所有员工。 + + +select job from emp where ename='周八'; +select * from emp where job in (select job from emp where ename='周八'); +-- 5、列出薪金等于部门30中员工的薪金的所有员工的姓名和薪金。 +-- +select * from emp where deptno=30; +select sum(sal) from emp where deptno=30; +select * from emp WHERE deptno not in (30); + + +-- 6、列出薪金高于在部门30工作的所有员工的薪金的员工姓名和薪金。 +-- +select sum(sal) from emp where deptno=30; +select * from emp where sal>(select max(sal) from emp where deptno=30); +-- 7、列出在每个部门工作的员工数量、平均工资、平均服务年限。 +-- +select deptno,avg(sal),count(deptno) from emp GROUP BY deptno; + +-- 8、列出所有员工的姓名、部门名称和工资。 +-- +select ename 姓名,dname 部门名称,sal 工资 from emp e LEFT JOIN dept d on e.deptno=d.deptno; +-- 9、列出所有部门的详细信息和部门人数。 +-- +select * from dept; +select d.deptno,loc,dname,count(*) from emp e,dept d where e.deptno=d.deptno group by d.deptno; + +-- 10、列出各种工作的最低工资。 +select job,min(sal) from emp GROUP BY job; +-- +-- 11、列出各个部门的 经理 的最低薪金。 +-- +select deptno,min(sal),job from emp where job='经理' GROUP BY deptno; + +-- 12、列出所有员工的年工资,按年薪从低到高排序。 +-- +select * from emp; +select ename 姓名,sal*12 年薪 from emp ORDER BY 年薪 desc; \ No newline at end of file -- Gitee