mysql作业2

命令综合 

1、mysql> select * from t_worker ;
2、mysql> select distinct department_id from t_worker ;
3、mysql> select count(1) from t_worker ;
4、mysql> select max(wages) '最高工资',min(wages)"最低工资" from t_worker ;
5、mysql> select avg(wages) '平均工资',sum(wages)"总工资" from t_worker ;
6、create table work_date (id int, name varchar(20),work varchar(20) );
7、mysql> select  name  ,year(now())-year(borth_date) from t_worker where politics like '党员';
8、mysql> select name  from t_worker where wages > 4000 and wages < 8000;
9、mysql> select name from t_worker where name like '孙%' or name like "李%";
10、
mysql> select department_id , worker_date ,name  from t_worker where department_id != 101 and politics not like '党员'
    -> group by department_id ,worker_date,name ;
11、mysql> select * from t_worker order by borth_date ;
12、mysql> select worker_id ,name from t_worker where wages = (select max(wages)from t_worker)
    -> order by wages desc
    -> limit 3 ;
13、mysql> select department_id ,count(1) from t_worker where politics like '党员'
    -> group by department_id;
14、mysql> select department_id ,round(avg(wages),2),sum(wages) from t_worker
    -> group by department_id;
15、mysql> select department_id ,count(1) from t_worker
    -> group by department_id
    -> having count(1) >= 3;

图表展示

 

 总结:

多种不同的查询方法要想熟练使用关键是面对要求要有清晰的思路要搞清楚命令的运行机制,清楚明白先后顺序,一步一步筛选信息最终达到目标

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值