1、首先找出每个部门的平均工资
SELECT AVG(salary) pjgz,did FROM man WHERE GROUP BY did
2、将其作为临时表,放到主查询中
SELECT man.name ,man.salary ,lsb.did ,lsb.pjgz
FROM man ,(SELECT AVG(salary) pjgz,did FROM man GROUP BY did) lsb
WHERE man.did =lsb.did AND man.salary > lsb.pjgz;
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/fonxian/article/details/47038423