with operatorList as ( select distinct c.partnerId as operatorId, opr.companyName as operatorName from tbl_TPM_Claims c with (nolock) inner join tbl_OPR_ClientOperators opr with (nolock) on opr.ownerId = c.ownerId and opr.fsltablecode = c.ownerType and opr.operatorId = c.partnerId where c.ownerId = and c.ownerType = and c.partnerType = 'OPR' and c.pendingDate is not null ), results as ( select row_number() over( order by operatorName ) as operatorKey, operatorId, operatorName from operatorList ) #forJSON( 'results', attributes.datastore, 'operatorKey' )#