Skip site navigation (1) Skip section navigation (2)

Re: count( distinct x )

From: Anthony <lists(at)a1(dot)org(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: count( distinct x )
Date: 2000-11-27 19:33:11
Message-ID: 3A22B6F7.50E8C122@a1.org.uk (view raw or flat)
Thread:
Lists: pgsql-sql
Kenn Thompson wrote:

> Ok- messy, but it works....
>
> CREATE VIEW testview AS
> select distinct area from areapostcode where postcode like 'BS1%';
>
> SELECT COUNT(*) FROM testview;
>
> kenn
>
> >>> Anthony <lists(at)a1(dot)org(dot)uk> 11/27/00 01:07PM >>>
> 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 <lists(at)a1(dot)org(dot)uk> 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.

CREATE VIEW testview AS
-> select distinct area from areapostcode where postcode like 'BS1%';
ERROR:  DISTINCT not supported in views

I think it's time to get Mr. Sysadmin to upgrade to v7 ;)

Thanks all, if anyone has an ideas of how to get this working on 6.5.3, then please help.
I'll check back in the morning, and try any suggestions, if no joy will try to get PostgreSQL
upgraded.

Thanks all.
Bap.


Responses

pgsql-sql by date

Next:From: Mathijs BrandsDate: 2000-11-27 19:34:13
Subject: Re: removing a DB??
Previous:From: AnthonyDate: 2000-11-27 19:25:52
Subject: Re: count( distinct x )

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group