>>>Using the following code I could Get the number of counts for Duplicate records. But How do I delete the Duplicate entries, i.e I just want to keep the one single entry for my account Number, Preferebly the last one.
>>>
>>>
>>>SELECT Accountno As Account_No,COUNT( * ) AS DupCount;
>>> FROM New_master ;
>>> INTO CURSOR Duplicates ;
>>> GROUP BY Accountno ;
>>> HAVING DupCount > 1
>>>
>>>
>>>I tried Select * from New_master UNION Select * from New_master . But It didn't worked.
>>
>>From the top of my head
>>
>>delete NM from New_Master NM ;
>>where exists (select 1 from (SELECT Accountno As Account_No,COUNT( * ) AS DupCount, MAX(AccountDate) as LastDate ;
>> FROM New_master ;
>> GROUP BY Accountno ;
>> HAVING DupCount > 1) X where X.Account_No = NM.AccountNo and NM.AccountDate < X.LastDate)
>---
>Thanks, I will try that. Madam, Please te;; where Should i start learning such SQL from Starting to complex one.?
I am not sure. I enjoy T-SQL and various SQL querying problems, so I participate a lot in MSDN T-SQL forum. Basically, the more you practice, the better you'll be.
If you want to learn T-SQL, you may start exploring Pinal Dave web site.
Here is my recent reply to a thread on a similar topic
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/51bd633e-4a8f-49be-9aed-bc0f0456a191
If it's not broken, fix it until it is.
My Blog