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

Re: select count of distinct rows

From: Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu>
To: "Foster, Stephen" <stephenlfoster(at)comcast(dot)net>,"'Jaime Casanova'" <systemguards(at)gmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: select count of distinct rows
Date: 2005-12-11 01:17:13
Message-ID: 006601c5fdf0$9e2f5e50$0200a8c0@OTTO (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

This works for me but the result is not that what is expected. I returns 
with the number of rows in the table, and the distinct has no effect because 
there is only one row in the result.

Best Regards,
Otto


----- Original Message ----- 
From: "Foster, Stephen" <stephenlfoster(at)comcast(dot)net>
To: "'Havasvölgyi Ottó'" <h(dot)otto(at)freemail(dot)hu>; "'Jaime Casanova'" 
<systemguards(at)gmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Sunday, December 11, 2005 2:12 AM
Subject: Re: [SQL] select count of distinct rows


Well this should work but I tried it and it didn't.

SELECT DISTINCT COUNT(*) FROM mytable;

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Havasvölgyi Ottó
Sent: Saturday, December 10, 2005 7:07 PM
To: Jaime Casanova
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] select count of distinct rows

Hi,

Yes, I need to compare all fields. Well, in this case it does not. Is
this
impossible?

Thanks,
Otto

----- Original Message ----- 
From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "Havasvölgyi Ottó" <h(dot)otto(at)freemail(dot)hu>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Sunday, December 11, 2005 1:57 AM
Subject: Re: [SQL] select count of distinct rows


On 12/10/05, Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu> wrote:
> Hi,
>
> I would like to select the count of distinct rows in a table.
>
> SELECT COUNT(DISTINCT *) FROM mytable;
>

are really all the fields distincts? the table doesn't have a pk?

> This does not work. How can I do it with Postgres?
>
> Thanks,
> Otto
>


--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org




---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date:
12/9/2005


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date:
12/9/2005



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org




In response to

pgsql-sql by date

Next:From: Frank BaxDate: 2005-12-11 01:23:14
Subject: Re: select count of distinct rows
Previous:From: Jaime CasanovaDate: 2005-12-11 01:16:22
Subject: Re: select count of distinct rows

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