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 1iczSX-0001rh-0v for pgsql-docs@arkaria.postgresql.org; Thu, 05 Dec 2019 22:18:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iczSV-0001HI-DF for pgsql-docs@arkaria.postgresql.org; Thu, 05 Dec 2019 22:18:51 +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 1iczSU-0001HA-Up for pgsql-docs@lists.postgresql.org; Thu, 05 Dec 2019 22:18:51 +0000 Received: from mail-oln040092004107.outbound.protection.outlook.com ([40.92.4.107] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iczSR-0007qs-FI for pgsql-docs@lists.postgresql.org; Thu, 05 Dec 2019 22:18:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EG9aAJOkm02TgCMOOW9ZfXzN4eqLv6KZi/aF3HQqNCDv9y6eUQTBh8p+kZw5Plku9xxBYCpbGgEc5vOrX53IoNCJ/Gks7i3m6aQf6jZuhEJYVgo9YhQp4sM3RBq8+X5bXUAR4wJHx7H8JDQ07P8suOWEblMhfoHtMz3AadTFtne1o3oXfirO1zJvlzXzRxT2JxozryAfrVbRMJ2ownOGTIQgysn19TVHgi7wTY1GjI0gYIYC1DRC3HygS7F9YqCI/S+n8lX701YUG3HOqSnM5uzN4m8OenCWTxdtjGyek105MZ1kZfLSN4C+bH7yyjL6xQWj8EaP1muBc6LXni2bfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g/Tmu4FzRemtgAs4tAKkex5GIV84Tp/aKrIZqyCDD0Q=; b=AzZow9HZlvW0Vmz3SKm2VhT7pl3qBY2ZzNP3q7sYo8MsFQI2tdOLzWQdHiMxlpGDkk2rJczNdAbDdgJehnBX6lURBR/8IHk0F3qH5Fm2ta4axq6GlY2xCS+uifY39oh+6ldHFNqb1ZW16KqYe+jbk4ZoRglNoH5vNDKxgb76L74knjnHc2H6YkHdBG1dkZ63X2wzXgfhBA73Dxt6nBvdM8sjYjIlJlED1niBJ1W/689VmwVxFlInRv0hOb8v4YNfqzGpwXZzqKbkw5bNSiVZdGC/omR/5rtLuI9CzRuKOSXVOuvPHVbxGbmiQtxXWBJ4B24jw8pOfCE+LK3RUBV9nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g/Tmu4FzRemtgAs4tAKkex5GIV84Tp/aKrIZqyCDD0Q=; b=fVhwEtd8QP4GC2KOilqfEAWz7Vuut2kHP+8FbrT8Mh34HSjzE0v7mXosDm1tkdI839x+/lcsl57T1lagjdf0ydXmVQHeZnvWgkF8+XY7Yb6M3EaOoRYsQQjXm2bWvdSkG/KigUqyiZoCidl7As3flCwxoMUblDD7JHLBDRwe7MIt1wZ/O8bR6aVSr1DCCcsp/MAPvzeb4tRQLSqwM+Dx3xFV+tOlB+fyzFagt7lDZkdhn6wPCjguT8Cne4K76AV7/ogIUtT4pJtKewYuRcqHOWz6wjWe7B8wX8KI2LI2buE0yO2wNsbyJf2IxonTIwX4GbHNNTGKM4fRVLUPHeIsnA== Received: from CY1NAM02FT013.eop-nam02.prod.protection.outlook.com (10.152.74.57) by CY1NAM02HT155.eop-nam02.prod.protection.outlook.com (10.152.75.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17; Thu, 5 Dec 2019 22:18:43 +0000 Received: from DM6PR06MB5562.namprd06.prod.outlook.com (10.152.74.56) by CY1NAM02FT013.mail.protection.outlook.com (10.152.75.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17 via Frontend Transport; Thu, 5 Dec 2019 22:18:43 +0000 Received: from DM6PR06MB5562.namprd06.prod.outlook.com ([fe80::8535:8b16:da9b:d2b7]) by DM6PR06MB5562.namprd06.prod.outlook.com ([fe80::8535:8b16:da9b:d2b7%6]) with mapi id 15.20.2516.014; Thu, 5 Dec 2019 22:18:42 +0000 From: John Lumby To: "pgsql-docs@lists.postgresql.org" Subject: description of Aggregate Expressions Thread-Topic: description of Aggregate Expressions Thread-Index: AQHVq7nzlaL7Neko7Em5IHgypYydWA== Date: Thu, 5 Dec 2019 22:18:42 +0000 Message-ID: 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> In-Reply-To: <2A91BEF8171A5349931391E0C721CC53757055C3@CPEMS-KPN501.KPNCNL.LOCAL> Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:66CAD33024D62CAFDB01A7F74A5D7908F59356B82F637AE734BEC6ECDF4AB84C;UpperCasedChecksum:019BD67E205A5BDC0BC488933D951F5111C3251BEE9713E4BE1BBC0B7E1166E3;SizeAsReceived:7434;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [PramLfLCAl3PBVsJXlryq3S3DdOU3d4D] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: aff0f901-0fbf-4c66-99c6-08d779d11644 x-ms-traffictypediagnostic: CY1NAM02HT155: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: D07jP7Z7p36idDh3GkVuClKxDx8GZ58JwVpzqxV5RKTn75iOVz+ShIx4+7rU/cGCC+mFmQciPryRx2YDI5dlcNoTXughANlUfczgCIvLZFI+IFh1cQOgRYqlYFzsRWgNyVOpyLlJI4D2hHXgzQqDAAxygVRzy37wqCeBicn0rsta9xxujvRXahBcwdKL9Jtv x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: aff0f901-0fbf-4c66-99c6-08d779d11644 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2019 22:18:42.3665 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT155 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk In PostgreSQL 12.1 Documentation chapter 4.2.7. Aggregate Expressions it s= ays=0A= =0A= =0A= The syntax of an aggregate expression is one of the following:=0A= ... =0A= aggregate_name (DISTINCT expression [ , ... ] [ order_by_clause ] ) [ FILTE= R ( WHERE filter_clause ) ]=0A= ...=0A= =0A= I believe this is incorrect in the case where the DISTINCT is on a comma-se= parated list of expressions.=0A= It would imply that this is legal=0A= =0A= select count(DISTINCT parent_id , name) from mytable=0A= =0A= but that is rejected with =0A= ERROR: function count(bigint, text) does not exist=0A= =0A= whereas =0A= =0A= select count(DISTINCT ( parent_id , name) ) from mytable=0A= =0A= is accepted.=0A= =0A= So I think to handle all cases the line in the doc should read=0A= =0A= aggregate_name (DISTINCT ( expression [ , ... ] ) [ order_by_clause ] ) [ F= ILTER ( WHERE filter_clause ) ]=0A= =0A= I don't know how to indicate that those extra parentheses can be omitted if= the list has only one expression.=0A= =0A= Cheers, John Lumby=