Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlFec-001xUq-Kn for pgsql-docs@arkaria.postgresql.org; Tue, 26 Sep 2023 21:31:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qlFeb-00FIjM-A9 for pgsql-docs@arkaria.postgresql.org; Tue, 26 Sep 2023 21:31:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlFeb-00FIj8-2H for pgsql-docs@lists.postgresql.org; Tue, 26 Sep 2023 21:31:37 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlFeX-007l7S-QZ for pgsql-docs@lists.postgresql.org; Tue, 26 Sep 2023 21:31:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=YVhLKtja7XRFbNgi4bq4vQE9OlTZN3nkx+7CB2uW1NI=; b=XWEj9 BumuoH5Vx/krv+sW3OBmJfty/dsdm6pif82eOLu4C19Pep3r9/5aXN4aToa9RuZAchLQEXwQ+Y3Co z9687Jv3esIeAC+PjAu7aikCg1qZoNSjIYHtp/iO44TqJOlhpUNullu1EZsFVE0yY7oxhJvQKJZrp rGWCo5ujZz+uFhlUKbPxbCtRlkUPe8xikV2C4yQRuwUno+iZF7TB78pf8cBgiJAZzTgeE+J3oBnZ3 2vAYWaJumAYvf3EKoqQdZ+MvsBIr89LOLDda4stDKjmJz7pERaNOinrdt37ENWJXDkHh1DIltIDoy HSNq/0sHg9Ew4An9rIX93wfrQg5+Q==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qlFeU-00HE3d-0R; Tue, 26 Sep 2023 17:31:30 -0400 Date: Tue, 26 Sep 2023 17:31:30 -0400 From: Bruce Momjian To: Tom Lane Cc: "David G. Johnston" , Laurenz Albe , postgres-hape@gmx.de, pgsql-docs@lists.postgresql.org Subject: Re: group by can use alias from select list Message-ID: References: <168871536004.379168.9352636188330923805@wrigleys.postgresql.org> <25b70e6ec7bef81acac508dc61dfa01e72c96252.camel@cybertec.at> <1591985.1694044890@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Sep 7, 2023 at 10:11:00AM -0400, Bruce Momjian wrote: > We do farther down the docs in the GROUP BY section: > > https://www.postgresql.org/docs/devel/sql-select.html > > GROUP BY will condense into a single row all selected rows that share > the same values for the grouped expressions. An expression used inside a > grouping_element can be an input column name, or the name or ordinal > number of an output column (SELECT list item), or an arbitrary > expression formed from input-column values. In case of ambiguity, a > ------------------------ > GROUP BY name will be interpreted as an input-column name rather than an > output column name. > > It says > > * input column name > * output column name or ordinal number > * expression formed from input-column values > > Is this too subtle? Patch applied back to PG 11. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.