Re: select count of distinct rows - Mailing list pgsql-sql

From Jaime Casanova
Subject Re: select count of distinct rows
Date
Msg-id c2d9e70e0512101716v396519a9s5d0ed9f4437d2d5c@mail.gmail.com
Whole thread Raw
In response to select count of distinct rows  (Havasvölgyi Ottó <h.otto@freemail.hu>)
List pgsql-sql
On 12/10/05, Havasvölgyi Ottó <h.otto@freemail.hu> wrote:
> Hi,
>
> I would like to select the count of distinct rows in a table.
>
> SELECT COUNT(DISTINCT *) FROM mytable;
>
> This does not work. How can I do it with Postgres?
>
> Thanks,
> Otto
>

I guess what you need is to know how many times a single row is
duplicated so i think what you need is something like this:

SELECT fld1, COUNT(DISTINCT fld1)  FROM (SELECT ROW(*) as fld1 FROM mytable) AS fooGROUP BY fld1;

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


pgsql-sql by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: select count of distinct rows
Next
From: Havasvölgyi Ottó
Date:
Subject: Re: select count of distinct rows