zoukankan      html  css  js  c++  java
  • 作业 5/6

    作业

    1.整理今日内容
    2.完成下列分组查询练习题(以课上建表代码为参考)
    	1. 查询岗位名以及岗位包含的所有员工名字
            select post,group_concat(name) from emp_utf8 group by post;
    	2. 查询岗位名以及各岗位内包含的员工个数
            select post,count(id) as '员工个数' from emp_utf8 group by post;
    	3. 查询公司内男员工和女员工的个数
        	select sex,count(sex) as '个数' from emp_utf8 group by sex;
    	4. 查询岗位名以及各岗位的平均薪资
        	select post,avg(salary) from emp_utf8 group by post;
    	5. 查询岗位名以及各岗位的最高薪资
        	select post,max(salary) from emp_utf8 group by post;
    	6. 查询岗位名以及各岗位的最低薪资
        	select post,min(salary) from emp_utf8 group by post;
    	7. 查询男员工与男员工的平均薪资,女员工与女员工的平均薪资
        	select group_concat(name),avg(salary) as '平均薪资' from emp_utf8 where sex = 'male';
            select group_concat(name),avg(salary) as '平均薪资' from emp_utf8 where sex = 'female';
    
    3.练习拼表操作并理解其意义
    create table wl1(id int primary key auto_increment,name char(10) not null) default charset utf8;
    create table wl2(id int primary key auto_increment,age int not null) default charset utf8;
    insert into wl1(name) values('a');
    insert into wl1(name) values('b');
    insert into wl1(name) values('c');
    insert into wl2(age) values(1);
    insert into wl2(age) values(2);
    insert into wl2 values(5,3);
    select * from wl1 inner join wl2 on wl1.id = wl2.id;
    select * from wl1 left join wl2 on wl1.id = wl2.id;
    select * from wl1 right join wl2 on wl1.id = wl2.id;
    select * from wl1 left join wl2 on wl1.id = wl2.id
    union
    select * from wl1 right join wl2 on wl1.id = wl2.id;
    4.理解子查询思路体会其意义
    首先,得到第一步产生的表,再在这个基础上继续筛选。
    
  • 相关阅读:
    题解-AtCoder ARC-083F Collecting Balls
    题解-CTS2019氪金手游
    题解-CTS2019随机立方体
    题解-APIO2019路灯
    题解-APIO2019桥梁
    vue-property-decorator 源码阅读
    如何在Vue项目中使用TypeScript
    在 Vue+TypeScript 项目中,如何配置 ESLint 和 Prettier
    JavaScript 原型和原型链
    pre-commit + imagemin 实现图片自动压缩
  • 原文地址:https://www.cnblogs.com/pythonwl/p/12838095.html
Copyright © 2011-2022 走看看