row_number用法

/opt/hive-0.9.0/bin/hive -e "use ent;add jar /work/yule/online/fastjson-1.1.31.jar;add jar /work/yule/online/JsonValueByKey.jar; create temporary function jsonkey as 'cn.focus.hadoop.sohu.JsonValueByKey';select a.userid, a.time, a.ct, a.num from (select userid, time,jsonkey(jsonkey(dataInfo, 'dataInfo'),'content') ct, row_number() over (partition by userid order by userid, time) num from t_origin_ugc_stat_online where datecol = '2015-03-29' and ugctype = 't_chat' and userid in (478826264) order by userid,time) a where num = 1;" > 20150329KOF_CHAT_ALL_CONTENT_FIREST_ONE.csv


参考
http://www.cnblogs.com/fxgachiever/archive/2010/09/15/1826792.html

猜你喜欢

转载自wangqiaowqo.iteye.com/blog/2197394