Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / b.v.rajaram

delete top (select count(*)-(select count(distinct empname )
from Employee) from Employee)from Employee
where a in (select distinct a from Employee)

Is This Answer Correct ?    0 Yes 1 No

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / v.krishnakumar

using the keyword distinct we can avoid the duplicate value
in our table,(ex) SELECT DISTINCT empname FROM Employee

Is This Answer Correct ?    0 Yes 1 No

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

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

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / jansi rani

SELECT EMPNAME,SAL FROM EMP GROUP BY EMPNAME,SAL

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What meant by Performance Tuning,how can we do the performance tuning on stored procedures and tell some steps to do the performance tuning

3 Answers   TCS,


What is filestream?

0 Answers  


What is resultset concur_updatable?

0 Answers  


How to change the password of a login name in ms sql server?

0 Answers  


Is it possible to have more then one foreign key in a single table? if possible, is this the good way to design the table?

2 Answers  


How to rename databases in ms sql server?

0 Answers  


What is thr feature of change data capture?

0 Answers  


how can do you the system monitoring?

1 Answers  


what is difference between NULL and ISNULL in SQL Server 2008?

0 Answers   MCN Solutions,


What is it unwise to create wide clustered index keys?

0 Answers  


What are mdf,ndf,ldf files and how to see the data in those files?

6 Answers   Accenture,


which table keeps the locking information? : Sql server administration

0 Answers  


Categories