no,date,attendance
12 2010-10-10 Y
13 2010-11-12 N
1)
思路:先查工资大于8000,再并列查询,小于5次
2010年小于5次的
select A.no count(A.no) from Attend A where attendance group by substring(date,0,4) having count(A.no)<5
故,综上得出结论
select E.no,E.name from Employee E left join Wage W on E.no=W.no left join (select A.no count(A.no) from Attend A where attendance group by substring(date,0,4) having count(A.no)<5)A on E.no=A.no where W.amount > 8000;
2)
思路:先查工资平均数,分别查不同的日期即可
select W.amount/sum(W.amoun),A.no,A.attendance/sum(A.attendance) from Attend A left join Wage W on W.no=A.no where substring(date,0,6)='201212' group by A.no
select W.amount/sum(W.amoun),A.no,A.attendance/sum(A.attendance) from Attend A left join Wage W on W.no=A.no where substring(date,0,6)='201201' group by A.no