use pay
select distinct professor from person;
–男员工信息
select no,name,sex,birthday,professor,deptno from person where sex = ‘男’;
–00102女员工信息
select no,name,sex,birthday,professor,deptno from person where deptno=00102 and sex = ‘女’;
–1.5倍工资后实际收入
select base*1.5+bonus-deduct as real_fact from pay where no = ‘000001’;
–00102基本信息
select person.no,name,sex,birthday,professor,deptno,base,bonus,deduct,fact
from person join pay on person.no = pay.no
where person.deptno = 00102
order by fact desc;
select deptno as ‘部门’,sum(fact) as ‘总额’
from pay,person
where pay.no = person.no and year = 2005
group by deptno;
–平均奖金升序排序
select deptname,avg(bonus) as 平均工资 from dept,pay,person
where dept.deptno = person.DeptNo and person.no = pay.no and year = 2005 and month = 1
group by dept.deptno,deptname
having avg(bonus) >