Обсуждение: COUNT(Distinct city) HELP!!!

Поиск
Список
Период
Сортировка

COUNT(Distinct city) HELP!!!

От
"Abe"
Дата:
Hey there,
 
I get this error but I think this is supposed to work:
 
The table has some duplicates such as Munich I want the number of distinct cities:
 
abenew=> select * from ct;
name|    age|    city
----        +---      +------
jow  |     10|     london
tim |      15|     paris
kim |     17|     munich
te   |      19|     munich
(8 rows)
 
My query is as follows:
 
tester => select count(distinct city) from ct;
ERROR:  parser: parse error at or near "distinct"
 
Any guidance would be appreciated...
Thanks
Abe

Re: COUNT(Distinct city) HELP!!!

От
Stephan Szabo
Дата:
I believe that functionality was added in version 7.0,
are you using an earlier version?

On Mon, 25 Dec 2000, Abe wrote:

> Hey there,
>
> I get this error but I think this is supposed to work:
>
> The table has some duplicates such as Munich I want the number of distinct cities:
>
> abenew=> select * from ct;
> name|    age|    city
> ----        +---      +------
> jow  |     10|     london
> tim |      15|     paris
> kim |     17|     munich
> te   |      19|     munich
> (8 rows)
>
> My query is as follows:
>
> tester => select count(distinct city) from ct;
> ERROR:  parser: parse error at or near "distinct"
>
> Any guidance would be appreciated...
> Thanks
> Abe
>


Re: COUNT(Distinct city) HELP!!!

От
GH
Дата:
On Mon, Dec 25, 2000 at 11:12:50PM -0000, some SMTP stream spewed forth:
> Hey there,
>
> I get this error but I think this is supposed to work:

Hrm, it works here on 7.0.2 where each field is "text".

=> select version();
                             version
-----------------------------------------------------------------
 PostgreSQL 7.0.2 on i386-unknown-freebsdelf4.0, compiled by cc
(1 row)


I wish that I could actually *help* you, but I can not. ;-(

G'luck.

gh

>
> The table has some duplicates such as Munich I want the number of distinct cities:
>
> abenew=> select * from ct;
> name|    age|    city
> ----        +---      +------
> jow  |     10|     london
> tim |      15|     paris
> kim |     17|     munich
> te   |      19|     munich
> (8 rows)
>
> My query is as follows:
>
> tester => select count(distinct city) from ct;
> ERROR:  parser: parse error at or near "distinct"
>
> Any guidance would be appreciated...
> Thanks
> Abe

Re: COUNT(Distinct city) HELP!!!

От
Anand Raman
Дата:
or u can also try

select count(*)
from
    (select distinct city from ct);

Hope this helps
Anand

On Mon, Dec 25, 2000 at 05:27:30PM -0800, Stephan Szabo wrote:
>
>I believe that functionality was added in version 7.0,
>are you using an earlier version?
>
>On Mon, 25 Dec 2000, Abe wrote:
>
>> Hey there,
>>
>> I get this error but I think this is supposed to work:
>>
>> The table has some duplicates such as Munich I want the number of distinct cities:
>>
>> abenew=> select * from ct;
>> name|    age|    city
>> ----        +---      +------
>> jow  |     10|     london
>> tim |      15|     paris
>> kim |     17|     munich
>> te   |      19|     munich
>> (8 rows)
>>
>> My query is as follows:
>>
>> tester => select count(distinct city) from ct;
>> ERROR:  parser: parse error at or near "distinct"
>>
>> Any guidance would be appreciated...
>> Thanks
>> Abe
>>

Re: COUNT(Distinct city) HELP!!!

От
"Abe"
Дата:
No Joy,
unfortunately - It may well be time to upgrade.

Thanks,
Abe


----- Original Message -----
From: "Anand Raman" <araman@india-today.com>
To: <pgsql-general@postgresql.org>
Sent: Tuesday, December 26, 2000 6:43 AM
Subject: Re: [GENERAL] COUNT(Distinct city) HELP!!!


> or u can also try
>
> select count(*)
> from
> (select distinct city from ct);
>
> Hope this helps
> Anand
>
> On Mon, Dec 25, 2000 at 05:27:30PM -0800, Stephan Szabo wrote:
> >
> >I believe that functionality was added in version 7.0,
> >are you using an earlier version?
> >
> >On Mon, 25 Dec 2000, Abe wrote:
> >
> >> Hey there,
> >>
> >> I get this error but I think this is supposed to work:
> >>
> >> The table has some duplicates such as Munich I want the number of
distinct cities:
> >>
> >> abenew=> select * from ct;
> >> name|    age|    city
> >> ----        +---      +------
> >> jow  |     10|     london
> >> tim |      15|     paris
> >> kim |     17|     munich
> >> te   |      19|     munich
> >> (8 rows)
> >>
> >> My query is as follows:
> >>
> >> tester => select count(distinct city) from ct;
> >> ERROR:  parser: parse error at or near "distinct"
> >>
> >> Any guidance would be appreciated...
> >> Thanks
> >> Abe
> >>
>