From: Anthony <lists@a1.org.uk>
To: pgsql-sql@postgresql.org
Subject: Re: count( distinct x )
Date: Mon, 27 Nov 2000 19:25:52 +0000
Message-ID: <3A22B53F.AEA491AB@a1.org.uk> (raw)
References: <Pine.BSI.4.21.0011271347030.11900-100000@glass.toledolink.com>
<3A22AEE0.4FD68ECF@a1.org.uk>
<3A22B2C7.5E46C1B6@mondo-live.com>
Najm Hashmi wrote:
> Anthony wrote:
>
> > Michael Fork wrote:
> >
> > > I think you want
> > >
> > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'
> > >
> >
> > psql still not happy :(
> >
> > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%';
> > ERROR: parser: parse error at or near "distinct"
> >
> > Thanks,
> > Bap.
> >
> > >
> > > 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.
> > > >
>
> Hi,
> I think this might work: It works on my machine, and I have postgres 7.xx
> SELECT distinct(count(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'
>
> Regrads
> Najm
no, this one succedes, but returns the count of
select area from areapostcode where postcode like 'BS1%'
not the count of
select distinct area from areapostcode where postcode like 'BS1%'
but I have just replied to this list with the following
select version();
version
-------------------------------------------------------------------
PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66
(1 row)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: lists@a1.org.uk
Subject: Re: count( distinct x )
In-Reply-To: <3A22B53F.AEA491AB@a1.org.uk>
References: <Pine.BSI.4.21.0011271347030.11900-100000@glass.toledolink.com> <3A22AEE0.4FD68ECF@a1.org.uk> <3A22B2C7.5E46C1B6@mondo-live.com> <3A22B53F.AEA491AB@a1.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox