>我有黑斑羚查询:
select id,zip,income
from zipcode_incomes
group by income
having income>avg(income)
但是我收到错误,分析异常:选择不是由聚合输出生成的列表表达式(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;
这将返回收入大于总体平均值的邮政编码。