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 / 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


Please Help Members By Posting Answers For Below Questions

How can you append an identity column to a temporary table?

1071


Where can you add custom error messages to sql server?

1215


What kind of problems occurs if we do not implement proper locking strategy?

1500


What are the kinds of subquery?

1109


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

1067


Can one drop a column from a table?

1091


How to provide default values to function parameters?

1261


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

2296


How do I find query history in sql server?

1025


What is a coalesce function?

1285


What are the properties of the transaction?

1074


Disadvantages of the indexes?

1225


What is sql or structured query language?

1228


How can we solve concurrency problems?

1123


How to convert numeric expression data types using the cast() function?

1151