Oralce in SQL delete duplicate data keep only one (go)

Source: Internet
Author: User
Tags how to use sql

with the SQL statement, delete duplicates only keep one in thousands of records, there are some identical records, how to use SQL statements, delete duplicates1, duplicate records in the lookup table are judged by a single field (Peopleid) .Select* frompeoplewherePeopleidinch(SelectPeopleid fromPeople GROUP by Peopleid have count (Peopleid) >1) 2, delete redundant records in the table, repeat records are based on a single field (Peopleid), leaving only the smallest rowid record delete frompeoplewherePeoplenameinch(SelectPeoplename fromPeople GROUP by Peoplename have count (peoplename) >1) and Peopleid notinch(SelectMin (Peopleid) fromPeople GROUP by Peoplename have count (peoplename) >1) 3, finding extra duplicate records in a table (multiple fields)Select* fromVitae awhere(A.PEOPLEID,A.SEQ)inch(SelectPeopleid,seq fromVitae GROUP BY PEOPLEID,SEQ have count (*) >1) 4, delete extra duplicate records (multiple fields) in the table, leaving only the rowID minimum record delete fromVitae awhere(A.PEOPLEID,A.SEQ)inch(SelectPeopleid,seq fromVitae GROUP BY PEOPLEID,SEQ have count (*) >1) and rowID notinch(SelectMin (ROWID) fromVitae GROUP BY PEOPLEID,SEQ have count (*) >1) 5, find redundant duplicate records (multiple fields) in the table, and do not contain ROWID minimum recordsSelect* fromVitae awhere(A.PEOPLEID,A.SEQ)inch(SelectPeopleid,seq fromVitae GROUP BY PEOPLEID,SEQ have count (*) >1) and rowID notinch(SelectMin (ROWID) fromVitae GROUP BY PEOPLEID,SEQ have count (*) >1)   6. Eliminate the first bit to the left of a field: Update TableNameSet[Title]=right ([title], (Len ([title])-1))whereTitle like'Village%'7. Eliminate the first bit to the right of a field: Update TableNameSet[Title]=left ([title], (Len ([title])-1))whereTitle like'% Village'8. False Delete redundant duplicate records (multiple fields) in the table, not including ROWID minimum records update vitaeSetispass=-1wherePeopleidinch(SelectPeopleid fromVitae GROUP BY Peopleid

Oralce in SQL delete duplicate data keep only one (go)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.