0
我正在写一个查询,需要GROUP BY一行的类型,然后将值除以总数,以知道IMPALA中的总数的百分比。 例:使用Impala中的SELECT语句进行算术运算
Name performance
something type1 something 15
something type1 something 18
something type2 something 23
something something something 345
something type2 something 23
SELECT
CASE WHEN name like '%type1%' then 'type 1'
WHEN name like '%type2%' then 'type2'
ELSE 'other' END as type
,sum(performance)/(SELECT sum(performance) FROM table)
FROM table
GROUP BY type
这让我AnalysisException的错误:子查询不在选择列表的支持。 任何人都可以建议我将如何解决这个问题?
我不明白,如果你真的来自同一个表中提取:'总和(性能)/(SELECT SUM(性能)FROM表) FROM table' – genespos