Re: count( distinct x ) - Mailing list pgsql-sql

From Anthony
Subject Re: count( distinct x )
Date
Msg-id 3A22B0ED.516F627F@a1.org.uk
Whole thread Raw
In response to count( distinct x )  (Anthony <lists@a1.org.uk>)
List pgsql-sql
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@a1.org.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.


pgsql-sql by date:

Previous
From: Anthony
Date:
Subject: Re: count( distinct x )
Next
From: Tom Lane
Date:
Subject: Re: count( distinct x )