finding duplicate numbers in a select distinct statement

From: Terry <td3201(at)gmail(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: finding duplicate numbers in a select distinct statement
Date: 2010-03-03 14:49:51
Message-ID: 8ee061011003030649q4014c591k880fa81366457c36@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

I am trying to do the following query but I would like to know how
many rows were deduplicated in the process:

psql -d foo -c 'SELECT DISTINCT ON (error) error,ev_text FROM
clients_event_log' -o fullfoo

For example, I would want the output to be the following where count
is the number of error rows that were deduplicated.

count | error | ev_text
55 | 525152 | Some text
72 | 125124 | Some other text

I imagine it's using the count function somewhere, just not sure how
to embed that.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Kempter 2010-03-03 14:51:38 Re: How to grant a user read-only access to a database?
Previous Message akp geek 2010-03-03 14:44:07 Re: FSM and VM file