标签:mod java avg end 技术分享 his lines 数据 function
表的结构(表名为sqltest)
1、首先找出每一个部门的平均工资
SELECT AVG(salary) avg_salary ,depart_id FROM sqltest GROUP BY depart_id
得到
2、将其作为暂时表(temp_table)。放到主查询中
SELECT sqltest.name,sqltest.salary,temp_table.depart_id,temp_table.avg_salary
FROM sqltest,(SELECT AVG(salary) avg_salary ,depart_id FROM sqltest GROUP BY depart_id) temp_table
WHERE sqltest.depart_id = temp_table.depart_id and sqltest.salary > temp_table.avg_salary;
得到
标签:mod java avg end 技术分享 his lines 数据 function
原文地址:http://www.cnblogs.com/gavanwanggw/p/7137835.html