Re: compare two rows - Mailing list pgsql-admin

From Richard Broersma
Subject Re: compare two rows
Date
Msg-id AANLkTimosiCc=95z_sHOUM2-rt5wGh23wTe_R8kC4k4_@mail.gmail.com
Whole thread Raw
In response to Re: compare two rows  (Ben Kim <bkim@tamu.edu>)
List pgsql-admin
On Tue, Oct 12, 2010 at 3:10 PM, Ben Kim <bkim@tamu.edu> wrote:

> create table test_dup (id serial primary key, val text);
> insert into test_dup(val)values('some text');
> insert into test_dup(val)values('some texta');
>
> select * from test_dup;
>  id |    val
> ----+------------
>  1 | some text
>  2 | some texta


  SELECT Array_agg( id ) AS duplicate_ids,  val
    FROM test_dup
GROUP BY val
HAVING COUNT(*) > 1;

   SELECT T1.id, T2.id, T.val
     FROM test_dup AS T1
INNER JOIN test_dup AS T2
     USING ( val );

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-admin by date:

Previous
From: Ben Kim
Date:
Subject: Re: compare two rows
Next
From: "Kevin Grittner"
Date:
Subject: Re: compare two rows