如何在Hive加入查询中获取最大计数

时间:2015-06-12 07:35:11

标签: hadoop hive hiveql

我有这个问题:

select 

a.item_page_productid,
b.category_id,
a.viewcount

from 

(select 
item_page_productid,
count(*) as viewcount
from views 
where  eventdate > to_date(days_sub(now(), 60))
group by item_page_productid
) a

join

(select
 product_id,
 category_id
 from catalog_products_in_categories
 where active = 't') b

 on a.item_page_productid=b.category_id

我要做的是将单个item_page_productid与单个category_id配对,item_page_productid配对是具有最高viewcount的那个。

有什么想法吗?

0 个答案:

没有答案