码迷,mamicode.com
首页 > 其他好文 > 详细

hive 函数学习

时间:2014-11-01 16:05:23      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   on   art   cti   bs   as   sql   

NAME PRICE
---- -----
AAA  1.59
AAA  2.00
AAA  0.75
BBB  3.48
BBB  2.19
BBB  0.99
BBB  2.50

I would like to get target table:

RANK NAME PRICE
---- ---- -----
1    AAA  0.75
2    AAA  1.59
3    AAA  2.00
1    BBB  0.99
2    BBB  2.19
3    BBB  2.50
4    BBB  3.48

Normally I would use ROW_NUMBER() OVER function, so in Apache Hive it would be:

select
  row_number() over (partition by NAME order by PRICE) as RANK,
  NAME,
  PRICE
from
  MY_TABLE
;

hive 函数学习

标签:io   ar   sp   on   art   cti   bs   as   sql   

原文地址:http://www.cnblogs.com/charlie-badegg/p/4067257.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!