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

Answer Posted / sumathy

Execute the following query for each duplicate value.

1.Delete duplicate of empname='A'

delete top(select count(*)-1 from employee where
empname='A') from employee where empname='A'

2.Delete duplicate of empname='D'

delete top(select count(*)-1 from employee where
empname='D') from employee where empname='D'

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?

1101


Tell me about the approaches which you used to counter the DI problems.

1344


Where sql server usernames and passwords are stored in a sql server?

985


Relational calculus is what type of language?

1032


Explain query editor regions

1039


How to create a view on an existing table in ms sql server?

1126


How can you check the level of fragmentation on a table?

1040


You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?

155


Mention the differences between sql server and mysql.

1010


What are the different types of collation sensitivity?

1117


What is use of except clause?

1092


What are the different Topologies in which Replication can be configured?

1183


Explain multiserver query

1037


what is hash nonclustered index

960


What is tcl in sql server?

1120