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
When columns are added to existing tables, what do they initially contain?
Explain acid?
What is a cursor, index in sql?
How do use Having,Group by,Group function in SQL?
What are a scheduled jobs or what is a scheduled tasks?
Write a Select Query to display title for each group of records, which are collected with Compute Clause? Like titlefield column-A column-B ..... ..... ..... Sum ... titlefield column-A column-B ..... ..... ..... Sum ...
What is fill factor and pad index?
What are extended events in sql server?
Tell me what is difference between clustered and non clustered index?
What is the Main Difference between ACCESS and SQL SERVER?
What is difference between order by and group by?
What are the authentication modes in sql server? How can it be changed?
What are cascading parameters in ssrs reports?
How and why use sql server?
Explain magic tables in sql server?