TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQL DELETE duplicate rows

SQL delete duplicate rows with sql, tutorial, examples, insert, update, delete, select, join, database, table, join

<< Back to SQL

SQL DELETE DUPLICATE ROWS

If you have got a situation that you have multiple duplicate records in a table, so at the time of fetching records from the table you should be more careful. You make sure that you are fetching unique records instead of fetching duplicate records.

To overcome with this problem we use DISTINCT keyword.

It is used along with SELECT statement to eliminate all duplicate records and fetching only unique records.

SYNTAX:

The basic syntax to eliminate duplicate records from a table is:

SELECT DISTINCT column1, column2,....columnN
FROM table _name
WHERE [conditions]

EXAMPLE:

Let us take an example of STUDENT table.

ROLL_NONAMEPERCENTAGEADDRESS
1AJEET MAURYA72.8ALLAHABAD
2CHANDAN SHARMA63.5MATHURA
3DIVYA AGRAWAL72.3VARANASI
4RAJAT KUMAR72.3DELHI
5RAVI TYAGI75.5HAPUR
6SONU JAISWAL71.2GHAZIABAD

Firstly we should check the SELECT query and see how it returns the duplicate percentage records.

SQL > SELECT PERCENTAGE FROM STUDENTS
ORDER BY PERCENTAGE;
PERCENTAGE
63.5
71.2
72.3
72.3
72.8
75.5

Now let us use SELECT query with DISTINCT keyword and see the result. This will eliminate the duplicate entry.

SQL > SELECT DISTINCT PERCENTAGE FROM STUDENTS
ORDER BY PERCENTAGE;
PERCENTAGE
63.5
71.2
72.3
72.8
75.5




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf