'presto query error column must be an aggregate expression or appear in GROUP BY clause
I have a problem with this query, its logic force me to group by just by date key and number, this error "a.recharge must be an aggregate expression or appear in GROUP BY clause", change entire logic and it's wrong, can you please help me?
%jdbc(presto)
select
a.date_key,
COUNT(DISTINCT(a.number)) as dist_number,
a.recharge,
b.amount,
sum(a.recharge)*1.0 / sum(coalesce (NULLIF(b.amount,0),1)) as prct
from(
(select
date_key,
number,
recharge
from table_1 where (date_key >= 20220101 and date_key <= 20220130)) as a
full outer join
(select
date_key,
number,
amount
from table_2 where date_key >= 20220101 and date_key <= 20220130) as b
on a.date_key = b.date_key
and a.number = b.number
)
group by a.date_key,
a.number
order by a.date_key
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
