Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kS1Et-0001bv-D3 for pgsql-general@arkaria.postgresql.org; Mon, 12 Oct 2020 17:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kS1Es-00087c-9o for pgsql-general@arkaria.postgresql.org; Mon, 12 Oct 2020 17:03:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kS1Es-00087F-1v for pgsql-general@lists.postgresql.org; Mon, 12 Oct 2020 17:03:58 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kS1Ep-0003wu-AD for pgsql-general@lists.postgresql.org; Mon, 12 Oct 2020 17:03:57 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 9F0DF3B34; Mon, 12 Oct 2020 19:03:52 +0200 (CEST) Date: Mon, 12 Oct 2020 19:03:52 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Column aliases in GROUP BY and HAVING Message-ID: <20201012170352.GA16328@hjp.at> References: <20201012141008.GA25581@hjp.at> <3091650.1602513603@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: <3091650.1602513603@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.=20 >=20 > 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. >=20 > (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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --9amGYk9869ThD9tj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl+EjHMACgkQ8g5IURL+ KF116hAAgaMqO0lIXEvJS3USSg0Vcd/RYx7ukkrXKKQgFAa7LkWTx98o30y+KCz9 V3ra2loq9JtB2JaPPzyqILG1bF9+3cuBn1IQ85mQnmmGaCCyBPetJ0JM5jWRi6O8 Kq6qoIERX4pSuyOY1pKYvVq56IBdUFmVkrax9kw6z69ZVm+ouZ+Tc1Fqx578GYFB hr/xJQvTAZ7FqjqsyrkSR1DCm/6Iw/EiBH/kIujE7gYwXIzbrmljfwfwgOdAa5bl weTsS/rnbPi1gtnNT1n6ixfocWgb9oNaZnaQxUtQZlpupOMGo5IENF1EjCJI69W6 hf5v6rOhBR3Cz55KYSyuDs38mlJqxE5FfuZiOAp0ntd6HbcEImgtuA7IP9/A4ZC8 +FBJMtZFbpQYnycHu0ScdkqQAmtwCYb1ALI3yuRuQEIHEaOLo4RATlmYGAffPMiW GTXpha7QxJez8UWBPgoQQI49CDUd7I9TDXXA9EP0SoLLg2209QcMYmuThPkpxJO0 EKWNJEhCnxncL2gIl/7p9lQHpTnMATocoyNJgEdfVes5PsU0Jq8bHnsDWr+vdUqg 9v3BsZrV+zRF/+tbp1IGHlNmKbMpCcBGy9IRgmLRIq2YIYBSY+QRXdMnzCZ4gsQK rjyFethbrVfzkao/KFcDpwv7kB9tLvhM90v7QbNlyVfhHO+rlFo= =AjOi -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--