首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

hive topN 兑现

2012-12-28 
hive topN 实现hive的topN实现hive的topN实现方式有很多种,网上有一些通过自己写的udf实现,下面将我写的sq

hive topN 实现
hive的topN实现

hive的topN实现方式有很多种,网上有一些通过自己写的udf实现,下面将我写的sql模式贴一下

核心原理通过group by 分组求和 之后 用order by 进行全局排序 之后在limit n 取你想要的 topn 排名

上sql:

select obj , cnt from ( select obj ,count(obj) as cnt from action_raw where verb ='SHARE_ALBUM' and log_date >= '2012-01-01' and log_date <= '2012-12-12' group by obj ) tmp order by cnt desc limit 10

热点排行