pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Havasvölgyi Ottó <h.otto@freemail.hu>
To: Jaime Casanova <systemguards@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: select count of distinct rows
Date: Sun, 11 Dec 2005 02:25:20 +0100
Message-ID: <007101c5fdf1$c03c7360$0200a8c0@OTTO> (raw)
References: <20051209053849.498E8F0BEC@svr2.postgresql.org>
	<003001c5fded$53a2c5a0$0200a8c0@OTTO>
	<c2d9e70e0512101716v396519a9s5d0ed9f4437d2d5c@mail.gmail.com>

Yes, almost. I need the list of all different rows.
It's syntax error at the *.
ROW(*)
          ^

Otto


----- Original Message ----- 
From: "Jaime Casanova" <systemguards@gmail.com>
To: "Havasvölgyi Ottó" <h.otto@freemail.hu>
Cc: <pgsql-sql@postgresql.org>
Sent: Sunday, December 11, 2005 2:16 AM
Subject: Re: select count of distinct rows


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 foo
 GROUP BY fld1;

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






view thread (11+ messages)  latest in thread

Message-ID: <007101c5fdf1$c03c7360$0200a8c0@OTTO>
Permalink:  ../007101c5fdf1$c03c7360$0200a8c0@OTTO/
Also on:    postgresql.org/message-id/007101c5fdf1$c03c7360$0200a8c0@OTTO

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: h.otto@freemail.hu, systemguards@gmail.com
  Subject: Re: select count of distinct rows
  In-Reply-To: <007101c5fdf1$c03c7360$0200a8c0@OTTO>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox