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 1geSF8-000564-U7 for pgsql-general@arkaria.postgresql.org; Tue, 01 Jan 2019 22:10:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1geSF5-00024d-UC for pgsql-general@arkaria.postgresql.org; Tue, 01 Jan 2019 22:10:31 +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 1geSF4-000240-5e for pgsql-general@lists.postgresql.org; Tue, 01 Jan 2019 22:10:31 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1geSEv-0001Ia-7G for pgsql-general@postgresql.org; Tue, 01 Jan 2019 22:10:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 585A3216C5; Tue, 1 Jan 2019 17:10:19 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 01 Jan 2019 17:10:19 -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=0 i56FyrrFxDennbCJckGeTCvD2/WE27LadXUT4rlLrM=; b=TxFQBJjzWUx/BaZA4 ktnpInXl9kll1FWzdJT+BIHWPKDFywfegyfg+mbo0QaBjZJE6F1DORaRSw4vUcey 29DTlNdw2Qj246erOIdVl6Bk0ZwPy24jf8StW4fIgBs2WQ8ctxCqvdZhdi2kLDc2 Kb1hrfsQnpgsykR0dsjGvOA27yEO4mSgqbL6oMSBS0PRAwGbNWZRqJq4ZbdFw3t7 Ooshlxbj0dviyzyY+SPKBjoNK9lGn7LA/FproD7kHahFJEh19zmR9LIr/e52VV57 3lPxdrKIZ3hKpNi8j66mfdOCjfMBYHklY4UDT84kHJUsGmHehO9HEHcM3YLNe1Nt yJ0dQ== 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=0i56FyrrFxDennbCJckGeTCvD2/WE27LadXUT4rlL rM=; b=TPIQ4Xxc6FW3M+4s0BEmwj4SyEC3GLZm6LftgIJTa/qXbAeoe8c+34LKw 3YC1KWxFYxuqhldGLZBzpypgX0mM5AdscN5gZPFjTSRSWqv7U88rANuH2D4w/RLg MeUsCMaDAvQiXaesKSw5n1qFNjiuNDLNIWuhx1c3o7b7kj3gcwe+t5oVHP410U5X SzIFG82PlpWn1XhTXoUCvwYyv0n3TkP2pPor5myDS4zkE7pEDXc5AeBTz21dvvza OR8PMoMrPR++JxNjpmPJifkDagz6E7oqMGt2zxWP39YTfiF4QshS4sjwOxpgLzH5 ijWopvCTJsEeJyN7cBKeGxtcKPWIQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrudeggdduheelucdltddurdegtdekrddttd dmucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhht necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecukfhppeejuddrvdduvddrudefgedrfeenucfrrghrrghmpehmrghilhhfrhho mheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvg hrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 761F310084; Tue, 1 Jan 2019 17:10:18 -0500 (EST) Subject: Re: Query help To: "David G. Johnston" Cc: John W Higgins , pgsql-general References: <073395bd-912c-2e4e-7892-58aa86283c52@aklaver.com> From: Adrian Klaver Message-ID: <59b4791a-119e-c61a-c879-4687eb02afcb@aklaver.com> Date: Tue, 1 Jan 2019 14:10:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 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 1/1/19 12:05 PM, David G. Johnston wrote: > On Tuesday, January 1, 2019, Adrian Klaver > wrote: > > On 1/1/19 11:26 AM, John W Higgins wrote: > > with accounts_over_total as ( > select accountid from transactions where sum(amount) >= 50 group > by accountid) > > > Unfortunately there is a hitch in the above:( > > select p_item_no from projection where sum(qty) > 100 group > by(p_item_no); > ERROR:  aggregate functions are not allowed in WHERE > > > Which is where the HAVING clause comes in.  It filters out groups based > on an expression containing an aggregate function. Hmm, guess I should spend more time reading the SELECT docs:) > > David J. -- Adrian Klaver adrian.klaver@aklaver.com