Select duplicated values

From: jeffrey <johjeffrey(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Select duplicated values
Date: 2011-11-21 22:23:05
Message-ID: b95e9cc0-87d4-4dd3-8b9a-977fbb09d5ad@o37g2000prn.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lets say that the primary key column is A. I am trying to select all
the rows with duplicated values in columns B, C, and D.

I am not too experienced in SQL syntax, and I've used the following:
select A from table_name where B+C+D in (select B+C+D from table_name
group by B+C+D having count(*)>1 )

I'm looking for a better way, since I am just adding the three columns
together right now.

Jeffrey

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2011-11-21 22:27:38 Re: Selective backup script
Previous Message Twaha Daudi 2011-11-21 22:06:15 Installing postgresql on windows 7