Wednesday, October 27, 2010

Oracle - Delete duplicate records from table

Table with Duplicate Records

Table Name: checkdup

ID    NAME    SALARY
1    Bijoy    10000
2    Ashish    20000
3    Rajesh    15000
4    Manoj    1400
6    rahul    14000
7    Suhas    12000
8    Ashish    25000
9    Bhavik    25666
10    Bijoy    12000

Delete from checkdup where rowid in
( select max(rowid) from checkdup group by name having count(name) > 1)



After Query

ID    NAME    SALARY
1    Bijoy    10000
2    Ashish    20000
3    Rajesh    15000
4    Manoj    1400
6    rahul    14000
7    Suhas    12000
9    Bhavik    25666

No comments:

Post a Comment