Thread: COUNT(Distinct city) HELP!!!
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)
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"
ERROR: parser: parse error at or near "distinct"
Any guidance would be appreciated...
Thanks
Abe
Abe wrote: > > Part 1.1 Type: Plain Text (text/plain) > Encoding: quoted-printable Try this: select count(distinct (city) ) from ct -- http://www.mohawksoft.com
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 >
Hey there, Just tried that - No luck - I am using version 6.5.0 - Maybe its just not available in this version. Any alternatives ? Thanks Guys, Abe ----- Original Message ----- From: "mlw" <markw@mohawksoft.com> To: "Abe" <abe@fish.tm>; "Hackers List" <pgsql-hackers@postgresql.org> Sent: Monday, December 25, 2000 11:23 PM Subject: Re: COUNT(Distinct city) HELP!!! > Abe wrote: > > > > Part 1.1 Type: Plain Text (text/plain) > > Encoding: quoted-printable > > Try this: > select count(distinct (city) ) from ct > -- > http://www.mohawksoft.com >
Abe wrote: > > Hey there, > > Just tried that - No luck - I am using version 6.5.0 - Maybe its just not > available in this version. > Any alternatives ? I have tried this on version 7.02. I assume 6.5 did not support it. > > Thanks Guys, > Abe > ----- Original Message ----- > From: "mlw" <markw@mohawksoft.com> > To: "Abe" <abe@fish.tm>; "Hackers List" <pgsql-hackers@postgresql.org> > Sent: Monday, December 25, 2000 11:23 PM > Subject: Re: COUNT(Distinct city) HELP!!! > > > Abe wrote: > > > > > > Part 1.1 Type: Plain Text (text/plain) > > > Encoding: quoted-printable > > > > Try this: > > select count(distinct (city) ) from ct > > -- > > http://www.mohawksoft.com > > -- http://www.mohawksoft.com