with tradeChannels as ( select distinct tc.codeValue, tc.label as primaryTradeChannel, tc.codeValue tradeChannel, tc.label as tradeChannelTxt from tbl_PRD_TradeChannels tc with (nolock) inner join tbl_PRD_TradeChannelLink tcl with (nolock) on tc.codeValue = tcl.tradeChannel and tcl.ownerType = and tcl.ownerid = where active = 'Y' ) #forJSON( 'tradeChannels', attributes.dataStore, 'tradeChannelTxt' )#