COUNT(Distinct city) HELP!!!

Started by Abeabout 25 years ago8 messages
#1Abe
abe@fish.tm

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

#2mlw
markw@mohawksoft.com
In reply to: Abe (#1)
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

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Abe (#1)
Re: COUNT(Distinct city) HELP!!!

I believe that functionality was added in version 7.0,
are you using an earlier version?

On Mon, 25 Dec 2000, Abe wrote:

Show quoted text

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

#4GH
grasshacker@over-yonder.net
In reply to: Abe (#1)
Re: COUNT(Distinct city) HELP!!!

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

Show quoted text

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

#5mlw
markw@mohawksoft.com
In reply to: Abe (#1)
Re: COUNT(Distinct city) HELP!!!

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

#6Abe
abe@fish.tm
In reply to: Abe (#1)
Re: COUNT(Distinct city) HELP!!!

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!!!

Show quoted text

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

#7Anand Raman
araman@india-today.com
In reply to: Stephan Szabo (#3)
Re: COUNT(Distinct city) HELP!!!

or u can also try

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

Hope this helps
Anand

Show quoted text

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

#8Abe
abe@fish.tm
In reply to: Abe (#1)
Re: COUNT(Distinct city) HELP!!!

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:

Show quoted text

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