Select top 2 rows in Hive

2019-04-04 00:06发布

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?

2条回答
萌系小妹纸
2楼-- · 2019-04-04 00:19
select * from employee_list order by salary desc limit 2;
查看更多
地球回转人心会变
3楼-- · 2019-04-04 00:28

Yes, here you can use LIMIT.

You can try it by the below query:

SELECT * FROM employee_list SORT BY salary DESC LIMIT 2
查看更多
登录 后发表回答