select distinct coalesce( segP.clientsegId, segC.clientsegId ) segmentId, coalesce( segP.description, segC.description ) segment from tbl_1FS_MappingQueue mq with (nolock) inner join tbl_OPR_ClientOperators opr with (nolock) on opr.ownerId = mq.operatorOwnerId and opr.fsltablecode = mq.operatorOwnerType and opr.operatorId = mq.operatorId inner join tbl_OPR_ClientSegments segC with (nolock) on segC.ownerId = opr.ownerId and segC.fsl_tablecode = opr.fsltablecode and segC.clientsegId = opr.oprSegment left outer join tbl_OPR_ClientSegments segP with (nolock) on segC.parentClientSegId = segP.clientSegId where mq.operatorOwnerId = and mq.operatorOwnerType = and mq.linkLevel = and nullif( opr.fsl_choId, 0 ) is null and nullif( mq.linkId, 0 ) is null order by segment for json path, include_null_values