Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Duplicates (Where Multiple Rows Match) 1

Status
Not open for further replies.

T0AD

Programmer
Jun 4, 2003
73
GB
I have a simple query like this:

Code:
SELECT ColA, ColB, ColC FROM TableA

I want to return all of the rows where there is more than 1 row where the values in these three columns are the same, ordered by ColA (including the duplicate rows!).

Any ideas?

There's a thin line between genius, and insanity!
 
Code:
SELECT a.*
FROM TableA a

INNER JOIN

(SELECT ColA, ColB, ColC
FROM TableA
GROUP BY ColA, ColB, ColC
HAVING COUNT(*) > 1) b

ON a.ColA = b.ColA AND a.ColB = b.ColB AND a.ColC = b.ColC
ORDER BY a.ColA
 
Thank you.

There's a thin line between genius, and insanity!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top