Find TOP 10 latest record for each BUYER_ID for yesterday's date

…衆ロ難τιáo~ 提交于 2019-11-29 08:27:51
  SELECT FIRST 10 *
    FROM TestingTable1
   WHERE buyer_id = 34512201
ORDER BY created_time DESC;

I am late answering this and I am sure you must be knowing the use of row_number function with Hive. Just an addition as a reference to previously good discussion.

select * from
(select buyer_id,item_id,created_time, row_number() over(partition by buyer_id over
created_time asc) row_num from yourtable)tab
where tab.row_num<=5;
Sanskar Suman
select * 
from (select buyer_id,item_id,created_time,row_num() over (partition by buyer_id order by created_time DESC)) a 
where a.row_num<=10
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!