【发布时间】:2021-05-31 10:49:19
【问题描述】:
我需要执行此查询来创建每个州和行业的平均增长率表
create table industry_growth as select state,sub_industry, avg(growth_percent)ind_growth from company_growth group by state, sub_industry having count(sub_industry>2);
我正在阅读这张桌子
state string
sub_industry string
companyname string
growth_percent double
但我不断收到此错误
失败:SemanticException [错误 10025]:第 1:45 行表达式不在 GROUP BY 键'sub_industry'
帮助!
【问题讨论】:
-
如果 sub_industry 在组中,那么这不能工作:有 count(sub_industry>2)。你想达到什么目的?请说明任务
-
我正在努力争取各州发展最快的行业
-
我认为括号是问题所在。你能试试这个
create table industry_growth as select state,sub_industry, avg(growth_percent)ind_growth from company_growth group by state, sub_industry having count(sub_industry)>2;- 请注意我把> 2放在计数之外。不过我不确定你的逻辑。 -
请提供一些有代表性的数据示例和预期结果
-
count(sub_industry>2) 应该做什么?你需要两个最好的 - 增长的 pwr 状态还是什么?