select distinct agreementNumber, agreementVersion, benefiicaryType from tbl_IMPORT_BlackSmithAgreements stage with (nolock) where stage.ownerType = and stage.ownerId = and stage.eai_batchid = and fseBeneficiaryId is null and benefiicaryType = 'Operator' select distinct opr.operatorId from tbl_IMPORT_BlackSmithAgreements stage2 with (nolock) inner join tbl_OPR_ClientOperators opr with (nolock) on opr.ownerId = stage2.ownerId and opr.fsltablecode = stage2.ownertype and opr.operatorId = stage2.fseBeneficiaryId and opr.oprCompanyType in ( '1', 'G', 'C' ) where stage2.ownerType = and stage2.ownerId = and stage2.eai_batchid = and stage2.benefiicaryType = and stage2.fseBeneficiaryId > 0 and stage2.agreementVersion = and stage2.agreementNumber =
#agreementNumber#_#agreementVersion# = #qmd_candidateBeneficiaries.recordCount#