adspace


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


Please Help Members By Posting Answers For Below Questions

What are the source of constraints?

1008


Can we do dml on views?

1037


How can we solve concurrency problems?

1122


Explain system functions or built-in functions? What are different types of system functions?

1065


What is a view in sql?

1040


How to convert character strings into numeric values?

1190


How to provide default values to function parameters?

1258


what is the Ticketing tool used in Wipro technologies at Bangalore...???

8230


Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60

2295


How do I find query history in sql server?

1024


Does view occupy space?

1019


How do I find the sql server version?

1102


What is clustered index

1085


How to remove duplicate rows from table except one?

1088


What is in place upgrade in sql server?

1125