How to find maximum avg

前端 未结 15 2212
长情又很酷
长情又很酷 2020-12-15 19:17

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:



        
15条回答
  •  独厮守ぢ
    2020-12-15 20:00

    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;
    

提交回复
热议问题