Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500
Output should be
A 200
B 300
C 400
D 500
Answer Posted / arijit mandal
DELETE FROM Employee a
WHERE ROW_NUMBER() <>
( SELECT MIN( ROW_NUMBER() )
FROM Employee b
WHERE a.empname = b.empname
AND a.salary = b.salary)
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
How to insert data with null values?
How do indexes help, types?
How do use Having,Group by,Group function in SQL?
Which tools are available to manage SQL Azure databases and servers?
What specific conditions database should meet, before you can bulk copy data into it using bcp?
What are acid properties of transaction?
What is measure group, measure? : sql server analysis services, ssas
Write SQL queries on Self Join and Inner Join.
How to reaname table name without using sp_Rename in sql server..?
What are the different sql server versions?
How to define output parameters in stored procedures?
What does null mean?
How do you test your database? : sql server database administration
Explain filtered indexes?
What is the difference between Triggers and Stored Procedure?