我有impala查询:
select id,zip,income
from zipcode_incomes
group by income
having income>avg(income)
但是我收到错误,AnalysisException:选择不是由聚合输出生成的列表表达式(GROUP BY子句中缺少?)。我犯了什么错误?
答案 0 :(得分:1)
select
中不能包含非聚合列。据推测,你想要这样的东西:
select id, zip, income
from (select zi.*, avg(zi.income) over () as avg_income
from zipcode_incomes zi
) zi
where income > avg_income;
这将返回收入大于整体平均值的邮政编码。