Hive getting top n records in group by query

后端 未结 6 1975
终归单人心
终归单人心 2020-12-07 17:47

I have following table in hive

user-id, user-name, user-address,clicks,impressions,page-id,page-name

I need to find out top 5 users[user-id,user-name,user-ad

6条回答
  •  不思量自难忘°
    2020-12-07 18:43

    select * from (select user_id,user-name,user-address,page,click,row_num() over (partition by page order by clicks desc) a where a.row_num<=5

    there might be a change in choosing the columns but the logic is correct.

提交回复
热议问题