思路:
使用row_number()函数增加一列,用count()函数增加一列。
再计算中位数。
floor()函数作用:返回小于等于该值的最大整数。
select id,company,salary
from(
select id,company,salary,
row_number() over(partition by company order by salary) as rank_num,
count(*) over(partition by company) as count_id
from employee
) as a
where rank_num in (floor((count_id+1)/2),floor((count_id+2)/2))