如何找到最大平均 [英] How to find maximum avg
本文介绍了如何找到最大平均的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示最高平均工资;但是,我似乎无法使其正常工作.
I am trying to display the maximum average salary; however, I can't seem to get it to work.
我可以获得要显示的平均薪水列表:
I can get a list of the average salaries to display with:
select worker_id, avg(salary)
from workers
group by worker_id;
但是,当我尝试显示带有以下项的最高平均工资列表时:
However, when I try to display a list of the maximum average salary with:
select max (avg(salary))
from (select worker_id, avg(salary)
from workers
group by worker_id);
它没有运行.我收到无效标识符"错误.如何使用每个工人的平均工资来查找每个工人的最高平均工资?
it doesn't run. I get an "invalid identifier" error. How do I use the average salary for each worker to find the maximum average for each worker?
谢谢.
推荐答案
聚合函数(例如avg)产生的列通常会获得任意名称.只需为其使用别名,然后在其上进行选择:
Columns resulting from aggregate functions (e.g. avg) usually get arbitrary names. Just use an alias for it, and select on that:
select max(avg_salary)
from (select worker_id, avg(salary) AS avg_salary
from workers
group by worker_id) As maxSalary;
这篇关于如何找到最大平均的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文