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.96) (envelope-from ) id 1wDz3w-003Y9G-32 for pgsql-docs@arkaria.postgresql.org; Sat, 18 Apr 2026 06:21:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDz3w-00CDQW-0L for pgsql-docs@arkaria.postgresql.org; Sat, 18 Apr 2026 06:21:52 +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.96) (envelope-from ) id 1wDMqD-005eOX-34 for pgsql-docs@lists.postgresql.org; Thu, 16 Apr 2026 13:33:10 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wDMqA-00000001PSr-2evl for pgsql-docs@lists.postgresql.org; Thu, 16 Apr 2026 13:33:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=/RYe6A8Ss8r4dmhodeEKbwYnwwbKDQ3teY38tUxnsFs=; b=5dzCJbOE0ciI3SDyOlVfyXmSqp 5TYU5cdWmnLnA6HVw/PG60XWrYiNOz2W3dFQr/J5/CvFJjj8hlpzq5RhwiyRj7NWgr7dlhDToyDbS 2cTN2mG2lNo+qihvNAiPHv5kNJUiknOgH/5lGRPIFiAygEYfBT3k82RgZifLvw//u6Wh+M4f2rVXg JkkJ7Y2pMU81XrhjBIrmb5NWZxrHLXIbAYZafO6f0ZEpK8UdJE3RM+uttidvKH9p7ASnm0UCSgPcy PfDbd6KubIqOCt+S3K25ccAC+nJYUOQoQHhHgnASrC8Q6MEKrIcftaNh2BhRjjmJlpUTzpgLXW82v l5jax6aw==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDMq8-003qKT-17 for pgsql-docs@lists.postgresql.org; Thu, 16 Apr 2026 13:33:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDMq6-008EGW-1l for pgsql-docs@lists.postgresql.org; Thu, 16 Apr 2026 13:33:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Unclear documentation and requirement of clarification To: pgsql-docs@lists.postgresql.org From: PG Doc comments form Cc: aravinat2001@gmail.com Reply-To: aravinat2001@gmail.com, pgsql-docs@lists.postgresql.org Date: Thu, 16 Apr 2026 13:32:48 +0000 Message-ID: <177634636825.403056.10912625029192163239@wrigleys.postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/18/tutorial-agg.html Description: Notice this particular section in the documentation of 2.7 Aggregrate Functions (https://www.postgresql.org/docs/current/tutorial-agg.html) : "If we wanted to know what city (or cities) that reading occurred in, we might try: SELECT city FROM weather WHERE temp_lo =3D max(temp_lo); -- WRONG but this will not work since the aggregate max cannot be used in the WHERE clause. (This restriction exists because the WHERE clause determines which rows will be included in the aggregate calculation; so obviously it has to be evaluated before aggregate functions are computed.) However, as is often the case the query can be restated to accomplish the desired result, here by using a subquery: SELECT city FROM weather WHERE temp_lo =3D (SELECT max(temp_lo) FROM weather);" This would be better off if it's mentioned that in this particular case, we actually need the aggregate function to be computed before the WHERE clause and that's why we are using a subquery.