Home > Ask the Oracle Database / Applications Experts > Questions & Answers > Deleting duplicates
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Deleting duplicates

Jason Law EXPERT RESPONSE FROM: Jason Law

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 30 September 2002

I want to delete the duplicate records from table and keep only one record.

Example: ID Name
1 Sinu, 2 Sinu, 3 Sinu, 4 Tinu, 5 Tinu

Output
1 Sinu, 4 Tinu


>

Having a unique ID makes this easy. By using a self referencing sub-query and the MIN aggregate function, you can determine the lowest ID for a given NAME. By deleting all but the lowest ID, you are left with a unique set of NAMEs.

delete from MyTable t1
  where id <> ( select min(ID) from MyTable t2 
                  where t2.Name = t1.Name )

For More Information


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts