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

This query is for sql server 2005 and higher version of sql
server. It will not run on older versions.



with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >3

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When columns are added to existing tables, what do they initially contain?

989


Explain acid?

1028


What is a cursor, index in sql?

1031


How do use Having,Group by,Group function in SQL?

1699


What are a scheduled jobs or what is a scheduled tasks?

863


Write a Select Query to display title for each group of records, which are collected with Compute Clause? Like titlefield column-A column-B ..... ..... ..... Sum ... titlefield column-A column-B ..... ..... ..... Sum ...

2001


What is fill factor and pad index?

963


What are extended events in sql server?

911


Tell me what is difference between clustered and non clustered index?

902


What is the Main Difference between ACCESS and SQL SERVER?

1079


What is difference between order by and group by?

965


What are the authentication modes in sql server? How can it be changed?

1065


What are cascading parameters in ssrs reports?

214


How and why use sql server?

966


Explain magic tables in sql server?

994