with affiliations as ( select DISTINCT opr.operatorid, opr.companyname from tbl_CRM_AffiliationProducts c with (nolock) inner join tbl_OPR_ClientOperators opr with (nolock) ON (c.affiliationOrgID = opr.operatorid) inner join tbl_PRD_Skus s with (nolock) ON (s.skuid = c.skuid) where s.ownerid = and s.fsl_tableCode = ) #forJSON( 'affiliations', attributes.dataStore, 'companyname' )#