Re: compare two rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 12, 2010 at 3:10 PM, Ben Kim <bkim@xxxxxxxx> 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

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux