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 1iEw2O-0000v3-Ap for pgsql-performance@arkaria.postgresql.org; Mon, 30 Sep 2019 13:48:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iEw2L-000465-Pc for pgsql-performance@arkaria.postgresql.org; Mon, 30 Sep 2019 13:48:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEw2L-00045b-GE for pgsql-performance@lists.postgresql.org; Mon, 30 Sep 2019 13:48:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEw2E-0003Y4-Q5 for pgsql-performance@lists.postgresql.org; Mon, 30 Sep 2019 13:48:25 +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 x8UDmGC0023496; Mon, 30 Sep 2019 09:48:16 -0400 From: Tom Lane To: Mariel Cherkassky cc: =?UTF-8?Q?F=C3=A9lix_GERZAGUET?= , pgsql-performance@lists.postgresql.org Subject: Re: distinct on extract returns composite type In-reply-to: References: Comments: In-reply-to Mariel Cherkassky message dated "Mon, 30 Sep 2019 16:42:02 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23494.1569851296.1@sss.pgh.pa.us> Date: Mon, 30 Sep 2019 09:48:16 -0400 Message-ID: <23495.1569851296@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mariel Cherkassky writes: > In my query I wrapped the columns with distinct : distinct (extract year... > , extract quarter..). > In your query you didnt wrap the columns with distinct but you just > mentioned it. I guess this is the difference, thanks ! Yeah. DISTINCT does not have an argument, it's just a keyword you can stick in after SELECT. So what you had as the select's targetlist was (expr,expr), which is read as an implicit row constructor, that is the same as ROW(expr,expr). One of many arguably not-well-designed things about SQL syntax :-( regards, tom lane