标签:
SELECT a.name, a.salary ,a.dept_id FROM emp a WHERE salary<(SELECT AVG(salary) FROM emp WHERE a.dept_id=dept_id GROUP BY dept_id);
SELECT a.name,a.salary ,a.dept_id FROM emp a,(SELECT dept_id, AVG(salary) avge FROM emp GROUP BY dept_id) b WHERE a.salary<avge AND a.dept_id=b.dept_id;
标签:
原文地址:http://www.cnblogs.com/godfatherback/p/4688695.html