select ownerId, ownerType, foodserviceRewardsId, min( operatorCompanyId ) operatorCompanyId, operatorId, count(*) mappingCount from tbl_FSR_OperatorCompanies group by ownerId, ownerType, foodserviceRewardsId, operatorId having count(*) > 1 delete tbl_FSR_OperatorCompanies where ownerId = and ownerType = and operatorId = and foodserviceRewardsId = and operatorCompanyId >