Received: from mail.netgates.co.uk (mail.netgates.co.uk [194.105.64.74]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eARJ7Ft66573 for ; Mon, 27 Nov 2000 14:07:15 -0500 (EST) (envelope-from lists@a1.org.uk) Received: from a1.org.uk (martha.netgates.co.uk [194.105.64.211]) by mail.netgates.co.uk (Mirapoint) with ESMTP id BAO00758 (AUTH anthony); Mon, 27 Nov 2000 19:07:25 GMT Message-ID: <3A22B0ED.516F627F@a1.org.uk> Date: Mon, 27 Nov 2000 19:07:25 +0000 From: Anthony X-Mailer: Mozilla 4.72 [en] (X11; I; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: count( distinct x ) References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200011/246 X-Sequence-Number: 277 Kenn Thompson wrote: > What about > > select count(*) from (select distinct area from areapostcode where postcode like 'BS1%') > select count(*) from (select distinct area from areapostcode where postcode like 'BS1%'); ERROR: parser: parse error at or near "select" Thanks, any more ideas? > > >>> Anthony 11/27/00 12:24PM >>> > Jose Rodrigo Fernandez Menegazzo wrote: > > > > 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. > > yes, it responds as if distinct is not in the query string. > > Thanks, > Bap.