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 a sub-report?
How raid can influence database performance?
how can you select rexcord(rows) from table A which is not present in Table B . Id being the FK in Table B referencing to ID Table A
What is the purpose of forms?
What is index, cluster index and nonclustered index?
What are locks in sql?
What happens if the update subquery returns no rows in ms sql server?
Is sql different from sql server?
Explain what is the function of sql server agent windows service?
Explain different types of Normalization.
You want to implement the one-to-many relationship while designing tables. How would you do it?
Explain what is raid and what are different types of raid levels?
how you can configure a running aggregate in SSRS?
What are the general features of sql server management studio? : sql server management studio
how can a database be repaired? : Sql server administration