I have table name TABLE1 that contains duplicate records as shown below:
ID TYPE AMOUNT NUMBER DATE
--- ---- ------ ------ ---------
1 AAA 10.00 AAA123 22-JUN-11
2 AAA 2.00 AAA123 22-JUN-11
3 AAA 10.00 AAA123 22-JUN-11
4 AAA 2.00 AAA123 22-JUN-11
5 AAA 10.00 AAA123 22-JUN-11
6 AAA 2.00 AAA123 22-JUN-11
7 AAA 10.00 AAA123 22-JUN-11
8 AAA 2.00 AAA123 22-JUN-11
... ... ... ... ...
100 AAA 10.00 AAA123 22-JUN-11
101 AAA 2.00 AAA123 22-JUN-11
In this case, I would like to remove ALL duplicate combination rows, except two using SQL or/via PL/SQL where AMOUNT (10.00 and 2.00). In addition, the duplicate recordes containing different amounts could be more than two such as shown below:
ID TYPE AMOUNT NUMBER DATE
--- ---- ------ ------ ---------
1 AAA 10.00 AAA123 22-JUN-11
2 AAA 2.00 AAA123 22-JUN-11
3 AAA 15.00 AAA123 22-JUN-11
4 AAA 25.50 AAA123 22-JUN-11
5 AAA 10.00 AAA123 22-JUN-11
6 AAA 2.00 AAA123 22-JUN-11
7 AAA 15.00 AAA123 22-JUN-11
8 AAA 25.50 AAA123 22-JUN-11
...
In the above example, I need to delete only 4 out of 8 records, where AMOUNT should remain 4 records (10.00, 2.00, 15.00 and 25.50). In other words, I have multiple groups of duplicates in one table (2 records for one, 4 for another, etc) - multiple rows where more than one exists.