标签:
先通过查询得到平均工资表,然后在联结查询平均工资表和员工表,Group by修饰count(*),Group by要在where子句之后,order by子句之前。
select a.*,avgsal,count(*) as number from emp as a,(select deptno,avg(salary) as avgsal from emp group by deptno) as b where a.deptno=b.deptno and a.salary>b.avgsal group by a.deptno order by a.deptno;
标签:
原文地址:http://www.cnblogs.com/masterlibin/p/5641664.html