How to delete duplicate row from table sql

If we want to delete the duplicate row from a table we can perform it by sq l. Consider the following SQ L query


 delete from PATIENT_INFO   
 where MrNo in (select MrNo  
         from PATIENT_INFO group by MrNo  
         having (count(PatientId))>1) and   
         PatientId not in (select min(PatientId)  
              from PATIENT_INFO   
              group by MrNo  
              having (count(PatientId))>1)  

Here PATIENT_INFO    is Table Name. and PatientId  is the primary key of the table. and we want to delete the duplicate MrNo  .

Popular posts from this blog

WPF Crystal Report Viewer Using SAP

mvc razor textboxfor change event change another textboxfor value

ASP.NET MVC razor SAP Crystal report