Have you ever needed to identify records in a file that are duplicate records and struggled to find an elegant, simple and quick solution without having to write a program every time?
Use the GROUP and COUNT(*) features of SQL together to identify the duplicate records in no time...
Include the key fields in both the SELECT and the GROUP fields (in the same order). The key fields are whatever fields are required to make the definition of 'duplicate' unique to your situation.
Don't forget that you can redirect the output of your SQL operations to a file or a report using the F13=Services and option 1 to Change session attributes.
SELECT CONO, ITEM, Count(*)
GROUP BY CONO, ITEM
HAVING count(*) > 1
This was first published in May 2001