with data as ( select distinct choId as agreementOwnerChoId, operatorName as agreementOwnerName from tbl_DW_1fsOperators#_tableSuffix# with (nolock) where ownerId = and ownerType = and purchasing = 'Y' and beneficiary = 'Y' ) select count(*) over() as fseRowCount, * from data where agreementOwnerChoId in ( ) #applyFilter( _dataStore.filter )# and #applyFilter( _dataStore.search )# order by agreementOwnerName offset #_dataStore.skip# rows fetch next #_dataStore.take# rows only for json auto, include_null_values