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
What is the stuff and how does it differ from the replace function?
What is resultset concur_updatable?
Can I delete event logs?
What are the extra roles available in msdb? : sql server security
if no size is defined while creating the database, what size will the database have? : Sql server administration
What is sql stored procedure?
How to sort the query output with order by clauses in ms sql server?
What are the essential components of sql server service broker?
When would you use it?
Ms sql server index?
When would you use a before or after trigger?
What are the advantages of using stored procedures in sql server?
Does partitioning improve performance?
What is perspective, have you ever created perspective? : sql server analysis services, ssas
What is the difference between mysql and mysqli?