Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id BAF8D476337 for ; Wed, 8 May 2002 19:39:21 -0400 (EDT) Received: from post.webmailer.de (natwar.webmailer.de [192.67.198.70]) by postgresql.org (Postfix) with ESMTP id 115724760FE for ; Wed, 8 May 2002 19:11:44 -0400 (EDT) Received: from ianb (pD9E0E1E0.dip.t-dialin.net [217.224.225.224]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id BAA01022; Thu, 9 May 2002 01:11:40 +0200 (MEST) Content-Type: text/plain; charset="iso-8859-1" From: Ian Barwick To: jdiehl@sandia.gov, pgsql-sql@postgresql.org Subject: Re: having trouble w/ having clause... Date: Thu, 9 May 2002 01:13:22 +0200 X-Mailer: KMail [version 1.4] References: <20020507215118.239013F33@dominion.dyndns.org> In-Reply-To: <20020507215118.239013F33@dominion.dyndns.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200205090113.22872.barwick@gmx.net> X-Archive-Number: 200205/64 X-Sequence-Number: 7700 On Wednesday 08 May 2002 22:58, Mike Diehl wrote: > Hi all, > > This is a simple question, but for the life of me, I can't see what is > wrong with this query: > > select host,slot,port,count(mac) as d from cam group by host,slot,port > having d>1; Try: select host,slot,port,count(mac) as d from cam group by host,slot,port having count(mac) > 1 See: http://www.postgresql.org/idocs/index.php?sql-select.html "output_name Specifies another name for an output column using the AS clause. This name= is=20=20=20=20 primarily used to label the column for display. It can also be used to ref= er to the column's value in ORDER BY and GROUP BY clauses. But the output_nam= e=20 cannot be used in the WHERE or HAVING clauses; write out the expression=20 instead." HTH Ian Barwick