On 2020-10-12 10:40:03 -0400, Tom Lane wrote:
> "Peter J. Holzer" writes:
> > In the GROUP BY clause I can use the alias year which was defined
> > earlier in SELECT.
>
> This is a pretty unfortunate legacy thing that we support because
> backwards compatibility (and because "GROUP BY 1" is so f
"Peter J. Holzer" writes:
> In my mental model of how SQL works, the clauses of an SQL query (if
> present) are processed in a certain order:
> FROM
> WHERE
> SELECT
> GROUP BY
> HAVING
> ORDER BY
> LIMIT
The SELECT list is certainly done after GROUP BY/HAVING. Consi