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 / devender kumar
This query is for sql server 2005 and higher version of sql
server. It will not run on older versions.
with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >3
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
How to stop a loop early with break statements in ms sql server?
When we should use @@error?
What is self join in sql server joins?
How to create new table with "create table" statements?
Comment,Datatypes are unlimited
What is factless fact table? : sql server analysis services, ssas
What are the advantages of user-defined functions over stored procedures in sql server?
What is the correct order of the logical query processing phases?
How to find out what is the default collation in a database?
What is the usage of sign function?
Do you think BCNF is better than 2NF & 3NF? Why?
What is bit data type?
How to list all login names on the ms sql server?
What programming language would you use to create embedded functions in ssrs?
What is merge statement?