HiveQL and rank()

前端 未结 2 847
终归单人心
终归单人心 2021-01-07 04:22

I can\'t understand HiveQL rank(). I\'ve found a couple of implementations of rank UDF\'s on the WWW, such as Edward\'s nice example. I can load and access the functions, bu

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 04:54

    With the Windowing and Analytics functions introduced in Hive 0.11, you can use:

    select SalesRepId, volume as amount , rank() over (order by V.volume desc) as rank from 
    (select SalesRepId,sum(amount) as volume from purchases group by SalesRepId) V;
    

提交回复
热议问题