使用coalesce函数只要超过一个expression,就会报错:
FAILED: ODPS-0130071:Semantic analysis exception - Expression not in GROUP BY key : line 8:9 ''$.table''
sql如下:
SELECT
md5(concat(aid,bid)) as id
,aid
, bid
, sum(amountdue) as amountdue
, coalesce(
sum(regexp_count(get_json_object(extended_x, '$.table.tableParties'), '{')),
decode(get_json_object(extended_x, '$.table'), NULL, 0, 1)
) as tableparty
, decode(sum(headcount),null,0,sum(headcount) ) as headcount
, 'a' as pt
FROM e_orders
where pt='20170425'
group by aid, bid
您好,group by 后面要把分组字段都要跟上,您表达
coalesce(
sum(regexp_count(get_json_object(extended_x, '$.table.tableParties'), '{')),
decode(get_json_object(extended_x, '$.table'), NULL, 0, 1)
) as tableparty
, decode(sum(headcount),null,0,sum(headcount) ) as headcount
返回值实际上也是字段,需要把整个表达式写在group by 后面
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。