Re: count( distinct x )

From: Michael Fork <mfork(at)toledolink(dot)com>
To: Anthony <lists(at)a1(dot)org(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: count( distinct x )
Date: 2000-11-27 18:47:37
Message-ID: Pine.BSI.4.21.0011271347030.11900-100000@glass.toledolink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I think you want

SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Mon, 27 Nov 2000, Anthony wrote:

> Apologies if this has been asked b4, but got this result when
> attemplting to search the archives on the website
>
> Not Found
>
> The requested URL /mhonarc/pgsql-sql/search.cgi was not found on this
> server.
>
>
> Apache/1.3.12 Server at postgresql.rmplc.co.uk Port 80
>
> 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%'
>
> Can anyone help?
>
> TIA
> Bap.
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Anthony 2000-11-27 18:58:40 Re: count( distinct x )
Previous Message Anthony 2000-11-27 18:24:45 Re: count( distinct x )