AnalysisException:select 列表表达式不是由聚合输出生成的(GROUP BY 子句中缺少?)
AnalysisException: select list expression not produced by aggregation output (missing from GROUP BY clause?)
我有 impala 查询:
select id,zip,income
from zipcode_incomes
group by income
having income>avg(income)
但我收到错误,AnalysisException:select 列表表达式不是由聚合输出生成的(GROUP BY 子句中缺少?)。我犯了什么错误?
select
中不能有非聚合列。据推测,你想要这样的东西:
select id, zip, income
from (select zi.*, avg(zi.income) over () as avg_income
from zipcode_incomes zi
) zi
where income > avg_income;
这个returns个邮政编码的收入高于总体平均水平。
我有 impala 查询:
select id,zip,income
from zipcode_incomes
group by income
having income>avg(income)
但我收到错误,AnalysisException:select 列表表达式不是由聚合输出生成的(GROUP BY 子句中缺少?)。我犯了什么错误?
select
中不能有非聚合列。据推测,你想要这样的东西:
select id, zip, income
from (select zi.*, avg(zi.income) over () as avg_income
from zipcode_incomes zi
) zi
where income > avg_income;
这个returns个邮政编码的收入高于总体平均水平。