在Oracle 11g中适当使用GROUP BY子句

时间:2014-07-09 10:03:44

标签: oracle oracle11g

我是oracle查询的初学者。 我作为HR和访问表Employees登录到数据库。

我的查询如下:

select department_id,min(avg(salary)) from employees.........

我希望根据department_id进行分组而不显示子查询来显示结果, 并使用子查询。

1 个答案:

答案 0 :(得分:0)

select department_id, 
       min(salary) as min_sal, 
       max(salary) as max_sal,
       avg(salary) as avg_sal
from employees
group by department_id

要么取最低工资或单列的平均值,要么不能同时取两者。使用单独的列来获取两者。

相关问题