【发布时间】:2017-02-21 20:54:54
【问题描述】:
我有这张桌子,每一行都捐出一笔:
sale_date salesman sale_item_id
20170102 JohnSmith 309
20170102 JohnSmith 292
20170103 AlexHam 93
我正在努力争取每天排名前 20 的销售员,我想出了这个:
SELECT sale_date, salesman, sale_count, row_num
FROM (
SELECT sale_date, salesman,
count(*) as sale_count,
rank() over (partition by sale_date order by sale_count desc) as row_num
from salesforce.sales_data
) T
WHERE sale_date between '20170101' and '20170110'
and row_num <= 20
但我明白了:
FAILED: SemanticException Failed to breakup Windowing invocations into Groups. At least 1 group must only depend on input columns. Also check for circular dependencies.
Underlying error: org.apache.hadoop.hive.ql.parse.SemanticException: Line 5:35 Expression not in GROUP BY key 'sale_date'
我不确定分组会在什么时候生效。有人可以帮忙吗?发送!
【问题讨论】: