Sort Within Category And Limit 5 For This Hive Table
I have a hive table A that has the following column USER ITEM SCORE U1 I1 S1 U1 I2 S2 ................... What I want is a table B such a format USER
Solution 1:
should be something like this :
select USER,collect_set(ITEM) from (
select USER, ITEM,row_number () over (partition by USER order by SCORE desc) RN
from A
) t1
where RN <= 5
group by USER;
Post a Comment for "Sort Within Category And Limit 5 For This Hive Table"