Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id SAA39317 for ; Wed, 15 Dec 1999 18:35:06 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id SAA19714; Wed, 15 Dec 1999 18:33:55 -0500 (EST) To: kaiq@realtyideas.com cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] having with sub select? In-reply-to: Your message of Wed, 15 Dec 1999 17:47:31 -0600 (CST) Date: Wed, 15 Dec 1999 18:33:55 -0500 Message-ID: <19712.945300835@sss.pgh.pa.us> From: Tom Lane writes: > select rep, sum(amount) > from orders > group by rep > having sum(amount) < (select quota from salesreps where empl_num = rep); > for the query, I got (I'm using 6.5.1): > ERROR: Illegal use of aggregates or non-group column in HAVING clause Seems to work OK in 6.5.3 and in current development sources ... I'm not quite sure why it fails in 6.5.1 and not in 6.5.3, because I can't find any indication that parse_aggs.c changed in between. But please update and see if you still have the problem. regards, tom lane