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

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;
 

你可能感兴趣的:(hive中:row_number()排序函数的使用)