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

前端 未结 3 1034
独厮守ぢ
独厮守ぢ 2020-12-18 12:39

This is the below table

CREATE TABLE IF NOT EXISTS TestingTable1 
( 
BUYER_ID BIGINT,
ITEM_ID BIGINT, 
CREATED_TIME STRING
)

And this is th

相关标签:
3条回答
  • 2020-12-18 13:04
    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
    
    0 讨论(0)
  • 2020-12-18 13:19

    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;
    
    0 讨论(0)
  • 2020-12-18 13:21
      SELECT FIRST 10 *
        FROM TestingTable1
       WHERE buyer_id = 34512201
    ORDER BY created_time DESC;
    
    0 讨论(0)
提交回复
热议问题