I\'m migrating from MySQL to Postgres. In MySQL I can use
select sum(clicks) c from table where event_date >= \'1999-01-01\'
group by keyword_id
having
Is there a setting in Postgres that will allow it to use column aliases in the having clause?
No. Implementations that allow references to SELECT
-list entries in HAVING
are going outside the standard.
You should use a subquery, e.g.
select
c
from (
select
sum(clicks) c
from table
where event_date >= '1999-01-01'
group by keyword_id
) x
where c > 10;
... or repeat the aggregate.