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 / honey
with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >1
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is difference between sql and sql server?
What are xml indexes?
what are different types of raid configurations? : Sql server database administration
How to create a dml trigger using create trigger statements?
how many no of arguments can be passed in procedures and functions
Can we use where and having clause together?
What new data source types were added in ssrs 2014?
What is the recovery model? List the types of recovery model available in sql server?
What is a not null constraint?
Does a specific recovery model need to be used for a replicated database? : sql server replication
How to create a dynamic cursor with the dynamic option?
What is snapshot report?
Can you tell me some of the common replication dmv's and their use? : sql server replication
What are the database objects? : SQL Server Architecture
What command must you use to include the not null constraint after a table has already been created?