with reasons as ( select reasonId, reasonName from tbl_CRM_NoSaleReasons with (nolock) where ownerId = and ownerType = ), reasonsFormatted as ( select * ,[#attributes.datastore.map[_mc]#] as [#_mc#] from reasons ) select *, count(*) over() as fseRowCount from reasonsFormatted order by reasonName for JSON PATH, INCLUDE_NULL_VALUES