Re: Column aliases in GROUP BY and HAVING

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Column aliases in GROUP BY and HAVING
Date: 2020-10-12 17:03:52
Message-ID: 20201012170352.GA16328@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2020-10-12 10:40:03 -0400, Tom Lane wrote:
> "Peter J. Holzer" <hjp-pgsql(at)hjp(dot)at> 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 frequently
> a handy shortcut).
[...]
> I think SQL versions newer than SQL92 disallow these references entirely.
>
> (I'm being fairly brief here, but this has all been litigated multiple
> times before. See the archives.)

That's ok, you've answered my question. Thanks.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John the Scott 2020-10-12 17:17:04 Re: rum index supported on pg13?
Previous Message Laurenz Albe 2020-10-12 16:16:16 Re: Any interest in adding match_recognize?