Hi,
I have a table/file which has duplicate records (Lets say there are 10 fields in a record. Out of which, if 5 fields put together are same across more than 1 record, then it is considered as a duplicate). I need to delete those duplicate records alone using a SQL statement embedded in a SQLRPGLE program.
1) I am able to successfully fetch the Total duplicate records using
SELECT Fld1, Fld2.. Fld5 From Table Group By Fld1.. Fld5 Having Count(*) > 1
Note: It returns only 1 record per set of duplicate records.
2) I want to delete all of those duplicate records returned by the above SELECT statement. I tried with DELETE statement. It is not working.
Basically I need to write an SQL statement which returns the result of all the duplicate records alone individually(Not 1 record per set of duplicates). And also need to delete the fetched duplicate records.
PLEASE HELP ME WITH THE SOLUTION. Heard that it is possible with SQL CURSORS. Haven't tried it yet. Any other way ?
I have a table/file which has duplicate records (Lets say there are 10 fields in a record. Out of which, if 5 fields put together are same across more than 1 record, then it is considered as a duplicate). I need to delete those duplicate records alone using a SQL statement embedded in a SQLRPGLE program.
1) I am able to successfully fetch the Total duplicate records using
SELECT Fld1, Fld2.. Fld5 From Table Group By Fld1.. Fld5 Having Count(*) > 1
Note: It returns only 1 record per set of duplicate records.
2) I want to delete all of those duplicate records returned by the above SELECT statement. I tried with DELETE statement. It is not working.
Basically I need to write an SQL statement which returns the result of all the duplicate records alone individually(Not 1 record per set of duplicates). And also need to delete the fetched duplicate records.
PLEASE HELP ME WITH THE SOLUTION. Heard that it is possible with SQL CURSORS. Haven't tried it yet. Any other way ?
Comment