hive中:row_number()排序函数的使用

版权声明:https://blog.csdn.net/lvtula https://blog.csdn.net/lvtula/article/details/82423105

https://blog.csdn.net/javajxz008/article/details/53493509

第一步:

select *,row_number() over(distribute by custno sort by recdate asc,appid asc,case when product=cardtype then '1' else '2' end asc) as rank  from tbl_custinfo where pt='20161015'

第二步:

select * from
  (select *,row_number() over(distribute by custno sort by recdate asc,appid asc,case when product=cardtype then '1' else '2' end asc) as rank  from tbl_custinfo where pt='20161015') a
where a.rank=1;
 

猜你喜欢

转载自blog.csdn.net/lvtula/article/details/82423105
今日推荐