Retrieve 3rd MAX salary in Hive

好久不见. 提交于 2019-12-08 09:06:45

You're definitely on the right track with windowing functions. row_number() is a good function to use here.

select name, salary
from (
  select name
    , salary
    , row_number() over (partition by country order by salary desc) idx
  from employee ) x
where idx = 3

when you order by salary, make sure that it is a numerical type, or it will not be sorted correctly.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!