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

how to delete duplicate rows from table

Answer Posted / anand

TABLENAME: testanand
DATA:
id vanme emailid age
-- ------ ---------- ------
1 Anand anand.kv@abc.com 29
2 Anand anand.kv@abc.com 28
3 Rajesh rajesh@abc.com 30
4 Rajesh rajesh@abc.com 31
5 Vinit vinit@abc.com 21
6 Vinit vinit@abc.com 25

DELETE FROM testanand WHERE id Not IN
(SELECT min(id) FROM testanand GROUP BY vname)

RESULTS:

id vanme emailid age
-- ------ ---------- ------
1 Anand anand.kv@abc.com 29
3 Rajesh rajesh@abc.com 30
5 Vinit vinit@abc.com 21

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the steps you will take to improve the performance of a poor performing query?

969


what is a transaction and what are acid properties? : Sql server database administration

1016


What is the New in SQL server 2008?

962


What is after dml trigger?

1004


Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?

128


How to modify the underlying query of an existing view?

981


What is self join in sql server joins?

1048


What do you understand by physical_only option in dbcc checkdb?

973


How do you troubleshoot errors in a SQL Server Agent Job?

1047


What is the maximum number of index per table?

1067


What is 'Join' and explain its various types.

1129


How to view existing indexes on an given table using sys.indexes?

1084


How to rename an existing column with the "sp_rename" stored procedure in ms sql server?

1093


How can I check if a view exists in a sql server database?

1027


What do you mean by authentication modes in sql server?

1077