要求
(1)
select * from t_worker;
(2)
select distinct department_id from t_worker;
(3)
select count(1)'总人数' from t_worker;
(4)
select max(wages)'最高工资',min(wages)'最低工资' from t_worker;
(5)
select avg(wages)'平均工资' , sum(wages)'总工资' from t_worker;
(6)
select worker_id '职工号' , name'姓名' , worker_date'参加工作日期' from t_worker;
(7)
select year(now())-year(borth_date)'党员年龄' from t_worker where politics='党员';
(8)
select name'姓名',wages'工资' from t_worker where wages>=4000 and wages<=8000;
(9)
select name'姓名' from t_worker where name like '孙%' or name like '李%';
(10)
select worker_id'职工号' , name'姓名' from t_worker where department_id in (102,103) and politics !='党员';
(11)
select name'名字', borth_date'生日' from t_worker order by borth_date asc;
(12)
select name'姓名' , worker_id'职工号' from t_worker order by wages desc limit 3;
(13)
select department_id'部门号',count(1)'党员人数' from t_worke where politics='党员' group by department_id ;
(14)
select department_id'部门号', sum(wages)'部门工资' , round(avg(wages),2)'部门平均工资' from t_worker group by department_id;
(15)
select department_id'部门号',count(1)'总人数' from t_worker group by department_id having count(1)>=3;