with data as ( select a.choId, a.operatorName, a.operatorAddress, a.operatorCity, a.operatorState, a.operatorZipCode, a.operatorSegment, a.channelSegment, a.mainSegment, a.subSegment, format( a.lastActivityDate, 'MM/dd/yyyy' ) lastActivityDate, a.operatorType, a.parentName, coalesce( a.parentChoId, 0 ) parentChoId, a.hasSubGroups, case when a.beneficiary = 'Y' then 1 else 0 end hasAgreements from tbl_DW_1fsOperators#_tableSuffix# a with (nolock) where a.ownerId = and a.ownerType = and a.parentChoId = and a.choId = ) #forJSON( 'data', attributes.datastore, 'operatorName' )#