Forum

How to Delete Dupli...
 
Notifications
Clear all

How to Delete Duplicate Records From Country Table?


Rakesh
Posts: 47
 Rakesh
Topic starter
(@Rakesh)
Joined: 1 year ago

Can you please help me to write a query to Delete Duplicate Records From Country Table?

3 Replies
KV Kumar
Posts: 27
Admin
(@vinodkrsetty)
Member
Joined: 2 years ago

Check this article https://www.sqlqueries.in/how-to-delete-duplicate-rows-from-a-table/   to know how to delete duplicate records in a table. 

Reply
Janani T
Posts: 36
 Janani T
(@Janani T)
Joined: 1 year ago

Let us take 3 columns ID, Name and Code from the country table. You can write a query something like.

Select   ID, Name, Code, Count(*) as CNT
 
          From Country
 Group By ID, Name, Code
 Having Count(*)=1
 
Reply
Rakesh
Posts: 47
 Rakesh
Topic starter
(@Rakesh)
Joined: 1 year ago

With CTE as

(

Select Gender, Salary, row_number() over ( order by Gender ) as rownum

From employees

)

Delete from employees where rownum>1;

Reply
Share: