569. 员工薪水中位数

1、题目描述

在这里插入图片描述
在这里插入图片描述
来源:力扣(LeetCode)

 

select * from 
(select  company,salary , @c := @c+1 as r from employee , (select @c :=0) c order by company , salary) a
join (select company,count(1) cnt from employee group by company) b on a.company = b.company
where a.r = b.cnt div 2 +1
or (b.cnt mod 2=0 and a.r = b.cnt div 2  ) 

 

posted @ 2020-04-26 15:34  漫漫长路远  阅读(245)  评论(0)    收藏  举报