【sql】top的问题

hive -e "
select
brand_code,
barndname_full,
item_third_cate_cd,
item_third_cate_name,
id1
from(
select
brand_code,
barndname_full,
item_third_cate_cd,
item_third_cate_name,
id1,
row_number() over(partition by brand_code,barndname_full order by id1 desc) rank
from
(select
brand_code,
barndname_full,
item_third_cate_cd,
item_third_cate_name,
count(*) as id1
from
gdm.table1 
where
dt = '2018-12-13'
and sku_valid_flag = 1
and item_valid_flag = 1
and sku_status_cd = '3001'
group by
brand_code,
barndname_full,
item_third_cate_cd,
item_third_cate_name) t
) t1
where rank = 1
"

posted on 2019-08-05 15:31  奋斗的芒果ai榴莲  阅读(108)  评论(0编辑  收藏  举报