615 Average Salary: Departments VS Company
Posted ffeng0312
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了615 Average Salary: Departments VS Company相关的知识,希望对你有一定的参考价值。
https://leetcode.com/articles/average-salary-departments-vs-company/
select date_formate(pay_date,‘%Y-%m‘) pay_month, e.department_id,
(case when avg(amount) = com_avg then ‘same‘
when avg(amount) > com_avg then ‘higher‘
else ‘lower‘ end) comparison
from salary s1
left join employee e on s.employee_id = e.employee_id
inner join
(select date_format(pay_date, ‘%Y-%m‘) pay_month, avg(amount) com_avg from salary group by date_formate(pay_date,‘%Y-%m‘)) s2
on s2.pay_month= date_formate(s1.pay_date,‘%Y-%m‘)
group by e.department_id,date_formate(pay_date,‘%Y-%m‘)
以上是关于615 Average Salary: Departments VS Company的主要内容,如果未能解决你的问题,请参考以下文章
1491. Average Salary Excluding the Minimum and Maximum Salary
LeetCode --- 1491. Average Salary Excluding the Minimum and Maximum Salary 解题报告
LeetCode --- 1491. Average Salary Excluding the Minimum and Maximum Salary 解题报告