Received: from homero.datascan-site.com ([216.230.142.66]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eARICHt60998 for ; Mon, 27 Nov 2000 13:12:17 -0500 (EST) (envelope-from rocket@homero.datascan-site.com) Received: from homero.datascan-site.com (localhost.datascan-site.com [127.0.0.1]) by homero.datascan-site.com (8.9.3/8.9.3) with SMTP id MAA31536; Mon, 27 Nov 2000 12:08:06 -0600 (CST) (envelope-from rocket@homero.datascan-site.com) From: Jose Rodrigo Fernandez Menegazzo Received: from 192.168.0.9 (SquirrelMail authenticated user rocket) by mail.datascan-site.com with HTTP; Mon, 27 Nov 2000 12:08:06 -0600 (CST) Message-ID: <1092.192.168.0.9.975348486.squirrel@mail.datascan-site.com> Date: Mon, 27 Nov 2000 12:08:06 -0600 (CST) Subject: Re: count( distinct x ) To: lists@a1.org.uk In-Reply-To: <3A229EBB.F55BA11@a1.org.uk> References: <3A229EBB.F55BA11@a1.org.uk> Cc: pgsql-sql@postgresql.org X-Mailer: SquirrelMail (version 0.5) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200011/242 X-Sequence-Number: 273 > The problem I have is with this statement: > > select count( distinct area ) from areapostcode where postcode like > 'BS1%' > > the above statement fails with > ERROR: parser: parse error at or near "distinct" > > I am not the greatest when it comes to SQL, but the pgsql docs implied > that the above would work. > > What I am trying to do is get a count of the no of matches from the > statement below > select distinct area from areapostcode where postcode like 'BS1%' > > Not the count of: > select area from areapostcode where postcode like 'BS1%' > I don't have where to try it, but have you tried: select distinct count(area) from areapostcode where postcode like 'BS1%' Rodrigo F.