
select *  from StockLicense where BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 
in (select BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1  from StockLicense
group by  BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 
having count( BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 )>1)
order by  BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 





delete from StockLicense where RecordKey in
(select max(RecordKey)  from StockLicense where BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 
in (select BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1  from StockLicense
group by BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 
having count( BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 )>1)
group by  BRANCH + TYPE + PREFIX+SRL+SNO+Sno1 + aType +aPrefix + aSerial + aSno + aSno1 
)
