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
Can we insert data into view sql server?
whats the maximum size of view state??
why would you call update statistics? : Sql server database administration
How to find related tables in sql server?
What is the difference between rank and dense_rank?
what is raid and what are different types of raid configurations? : Sql server database administration
What is transaction server consistency?
What is Transparent Data Encryption?
Do you think BCNF is better than 2NF & 3NF? Why?
If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
Sql server reporting services vs. Crystal reports.
Explain what is scheduled job and how to create it?
What does COMMIT command do?
How to implement service broker?
How to provide values to user defined function parameters?