语法error:group by 子句不能包含聚合或窗口函数

xcitsw88  于 2021-08-13  发布在  Java
关注(0)|答案(2)|浏览(869)
select json_extract(other_detail,'$.is_substitute_allowed') as substitute,
       count(date(order_date)) as order_date 
from prescription_metrics 
group by 1;

我无法按aws雅典娜中其他\u细节(只能是0或1)的提取值进行分组“other\u detail”是json,而order\u date是date类型。错误:
group by子句不能包含聚合或窗口函数。
当不使用groupby时,查询可以正常工作

drnojrws

drnojrws1#

一个简单的解决方案是使用嵌套查询:

select substitute, order_date from 
(select json_extract(other_detail,'$.is_substitute_allowed') as substitute,
       count(date(order_date)) as order_date 
from prescription_metrics)
group by 1;

顺便说一句,你是说 count(distinct(order_date)) 或任何其他日期操纵( day ?)在“订单日期”列中?

ni65a41a

ni65a41a2#

请尝试下面的查询,

select json_extract(other_detail,'$.is_substitute_allowed') as substitute, count(date(order_date)) as order_date from prescription_metrics group by json_extract(other_detail,'$.is_substitute_allowed');

相关问题