I am trying to calculate the payments for each age range in PostgreSQL.
select
case
when age < 50 then "0-50"
else "50+"
end as age_range,
SUM(payment_amount) as sum_payment_amount
from
(
select
age,
payment_amount
from
"002_DM_clients" dc
left join user_payment_log upl
on
dc.client_id = upl.client_id
) query1
group by
age_range;
But I get the following error:
Error executing query:
SQL Error [42703]: ERROR: column "0-50" does not exist
I have no idea what the problem could be.