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 1ianIf-0003vR-TC for pgsql-general@arkaria.postgresql.org; Fri, 29 Nov 2019 20:55:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ianIe-0005RE-MR for pgsql-general@arkaria.postgresql.org; Fri, 29 Nov 2019 20:55:36 +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 1ianIc-0005Qy-H3 for pgsql-general@lists.postgresql.org; Fri, 29 Nov 2019 20:55:36 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ianIY-0007gA-AJ for pgsql-general@postgresql.org; Fri, 29 Nov 2019 20:55:34 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id DA8DC2279B; Fri, 29 Nov 2019 15:55:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 29 Nov 2019 15:55:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=w OdRnZxd4fkuMsCNj4OofivoWwQmW5j0MBhkf5bmMCM=; b=sq8r2dCeFitXLa/pY 9GPLuQBrxa4pEF98d4tNcuU/SkCrZxGdQAwuKS1aHmW39/vTB7HelVw4W8+vE77K O/z1qQrewvbjaoCt3FHZLMij5BteTpjazf8qacCwov/rnzq4BfghnhAfyM1xYqJ2 UZ+JTgp/jRglPlNTcyjwIS+II2E+X37km+8DsKnnWau+USdyXuhq+QbK2kEKJMmu ieMAgjOl8p1X7uHocJyZwRrLlWZWshRpfTg6rTICN9ZdGM6HB9uNNRjwq4BG5uIg 2F6YSLRGFDaBrePODE+s60EJOQtNjog8tVwtc02f6SDlOuQMdWjUygfA2XgFwZgy 1ZCwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=wOdRnZxd4fkuMsCNj4OofivoWwQmW5j0MBhkf5bmM CM=; b=GYmub5Q3EhqI576vCWcyjE0wi2W/jOC8R4TtJE4VdLcToVpmWa90cfb3q 7V+0nFda1w6+MxjGqev6gmvQrvB+I4mDND4HMXaZPD8Er4ZRGtJa0MXobMrYIt3M Ix5YktdznkxRNc6/0wVPTZI7S8xXWnM0spXY0nWs/95PAfyiVTFGaylSIvYDXamM SxbMbkv7bsbYIxcGr/m6Y/5CxVVnF6QQ20eZgF8bcmw3apo4qXjjdf6UjoTq0a/Z vMkavMAzbWDFDfOiWhsJaNO9RFDTc7VEJINiY/CG3oe2rGDpdxS5TB9CFx4cgZ/r xZqc8k5Z4QG+NOSYQWij495jAWKYQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudeiledgudeflecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecukfhppedujeegrddvuddrieekrddvgeefnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.2] (174-21-68-243.tukw.qwest.net [174.21.68.243]) by mail.messagingengine.com (Postfix) with ESMTPA id 5E23B30601BC; Fri, 29 Nov 2019 15:55:27 -0500 (EST) Subject: Re: Counting booleans in GROUP BY sections To: Alexander Farber Cc: pgsql-general References: From: Adrian Klaver Message-ID: <082dc4bf-e668-f091-9d96-9725dd5ddfee@aklaver.com> Date: Fri, 29 Nov 2019 12:55:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/29/19 11:47 AM, Alexander Farber wrote: > Thank you Adrian, but - > > if I remove GROUP BY mid, then I get the error: > > ERROR:  42803: column "words_moves.mid" must appear in the GROUP BY > clause or be used in an aggregate function > LINE 18:         mid, >                  ^ > LOCATION:  check_ungrouped_columns_walker, parse_agg.c:1369 Yes because it is a case of opposing forces. When you remove mid from the GROUP BY you get an single row for each group that has an aggregated output where you can have count of > 1. In that case the database has more then one choice for the mid to display and so it throws the error. To go forward it would help to know what it is you are trying to achieve? > > Regards > Alex -- Adrian Klaver adrian.klaver@aklaver.com