Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1id0Z5-00049U-7E for pgsql-docs@arkaria.postgresql.org; Thu, 05 Dec 2019 23:29:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1id0Z3-0007r4-E2 for pgsql-docs@arkaria.postgresql.org; Thu, 05 Dec 2019 23:29:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1id0Z3-0007qx-3L for pgsql-docs@lists.postgresql.org; Thu, 05 Dec 2019 23:29:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1id0Z0-0008SI-RS for pgsql-docs@lists.postgresql.org; Thu, 05 Dec 2019 23:29:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xB5NTYaQ025459; Thu, 5 Dec 2019 18:29:34 -0500 From: Tom Lane To: "David G. Johnston" cc: John Lumby , "pgsql-docs@lists.postgresql.org" Subject: Re: description of Aggregate Expressions In-reply-to: References: <2A91BEF8171A5349931391E0C721CC5375705457@CPEMS-KPN501.KPNCNL.LOCAL> <251962385fdc49da0da54e22588aabd6fbc2e0fa.camel@osdev.nl> <2A91BEF8171A5349931391E0C721CC53757054D3@CPEMS-KPN501.KPNCNL.LOCAL> <2CB4B3C9-F43F-49D8-A594-93DBE99EF514@elevated-dev.com> <7308f0f3a1674a39bada8571189a3735@CPEMS-KPN509.KPNCNL.LOCAL> <91CEBEAA-7260-4503-832F-E5B27B91BE1F@elevated-dev.com> <2A91BEF8171A5349931391E0C721CC5375705528@CPEMS-KPN501.KPNCNL.LOCAL> <2A91BEF8171A5349931391E0C721CC53757055C3@CPEMS-KPN501.KPNCNL.LOCAL> Comments: In-reply-to "David G. Johnston" message dated "Thu, 05 Dec 2019 16:06:12 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25457.1575588574.1@sss.pgh.pa.us> Date: Thu, 05 Dec 2019 18:29:34 -0500 Message-ID: <25458.1575588574@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Thu, Dec 5, 2019 at 3:18 PM John Lumby wrote: >> whereas >> select count(DISTINCT ( parent_id , name) ) from mytable >> is accepted. > Correct, converting the two individual columns into a "tuple" allows the > default tuple distinct-making infrastructure to be used to execute the > query. Yeah. This might be more intelligible if it were written select count(DISTINCT ROW(parent_id, name) ) from mytable However, the SQL committee in their finite wisdom have decreed that the ROW keyword is optional. (As long as there's more than one column expression; the need for that special case is another reason why omitting ROW isn't really a nice thing to do.) regards, tom lane