Select top 2 rows in Hive

那年仲夏 提交于 2020-01-12 11:56:13

问题


I'm a noobie here. I'm trying to retrieve top 2 tables from my employee list based on salary in hive (version 0.11). Since it doesn't support TOP function, is there any alternatives? Or do we have define a UDF?


回答1:


Yes, here you can use LIMIT.

You can try it by the below query:

SELECT * FROM employee_list SORT BY salary DESC LIMIT 2



回答2:


select * from employee_list order by salary desc limit 2;


来源:https://stackoverflow.com/questions/30441744/select-top-2-rows-in-hive

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