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


if 3 duplicate records in a table,i want to delete 2 duplicate
records by keeping 1 as it is,how?



if 3 duplicate records in a table,i want to delete 2 duplicate records by keeping 1 as it is,how?..

Answer / venkat

if u r table like this
sno sname fee
1 a 1000
1 a 1000
2 b 1000
2 b 1000
3 c 1000
3 c 1000
--- write this
with duplicatecte
as
(select row_number()over(partition by sno,sname order by fee
)as rnum from students )
delete from dupcte where rnum>1

---run this query
select * from students
--out put is
1 a 1000
2 b 1000
3 c 1000

this is correct

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Do you know spatial data types - geometry and geography in sql server 2008?

0 Answers  


How to specify the collation for a character data type in ms sql server?

0 Answers  


What is the diff between Static Queries and Dynamic queries give me some examples

2 Answers   CSC,


What is bit data type?

0 Answers  


What are the steps to process a single select statement?

0 Answers  


what's the difference between SQL & MY-SQl...? And what we learn from these ....?

2 Answers   Broadridge,


Do you know what is a with(nolock)?

0 Answers  


What is the purpose of a table?

0 Answers  


Define primary key?

0 Answers  


We are updating a field in sql and alter the row also.after giving the commit command the system is crashed.what will happen to the commands given,whether it will update and alter the table or not?

0 Answers   Amdocs, Apps Associates,


What is 5nf in normalization form?

0 Answers  


What does top operator do?

0 Answers  


Categories