【发布时间】:2014-05-12 15:45:43
【问题描述】:
伙计们,
我们有一个要求,我们希望在将 HIVE 表与 self 连接后应用 group by 子句。
例如数据
CUSTOMER_NAME,PRODUCT_NAME,PURCHASE_PRICE
customer1,product1,20
customer1,product2,30
customer1,product1,25
现在我们要通过考虑所有产品的总和以及随后按 CUSTOMER_NAME、PRODUCT_NAME 分组的结果集来获取客户(仅进行价格总和后的前 5 个客户,产品名称不存在于子查询中)
select customer_name,product_name,sum(purchase_price)
from customer_prd cprd
Join (select customer_name,sum(purchase_prices) order by sum group by customer_name limit 5) cprdd
where cprd.customer_name = cprdd.customer_name group by customer_name,product_name
收到错误消息说不能在 HIVE 中像这样分组?
【问题讨论】: