Forum

How to Delete Dupli...
 
Share:
Notifications
Clear all

How to Delete Duplicate Records From Country Table?

4 Posts
2 Users
0 Reactions
1,240 Views
Posts: 46
Topic starter
(@Rakesh)
Joined: 6 years ago

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


3 Replies
Posts: 27
Admin
(@vinodkrsetty)
Eminent Member
Joined: 7 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
Posts: 36
(@Janani T)
Joined: 6 years 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
Posts: 46
Topic starter
(@Info User 1)
Joined: 6 years ago

With CTE as

(

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

From employees

)

Delete from employees where rownum>1;


Reply

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: