Display duplicate rows in a table
How to Display duplicate rows in a table?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Nov 27, 2012, 12:59 AM EST
SELECT UserName,
COUNT(UserName) AS TotalOccurrences
FROM users
GROUP BY UserName
HAVING ( COUNT(UserName) > 1 )
Shankar MRank #874 · 2.5K reputationPosted Nov 27, 2012, 1:25 AM EST
You can get the entire duplicate row details for the columns being compared something like this,
SELECT *
FROM EMP A
WHERE EXISTS (SELECT 1
FROM EMP
WHERE empno = A.empno AND ROWID < A.ROWID)
Thanks,
Shankar