with data as ( select distinct prodline_id, productLineCode + ' - ' + productLine as productLine from tbl_DW_ProductHierarchy#_tableSuffix# with (nolock) where ownerId = and ownerType = and prodline_id > 0 and operatorPurchasing = 'Y' ) select count(*) over() as fseRowCount, * from data where prodline_id in ( ) #applyFilter( _dataStore.filter )# and #applyFilter( _dataStore.search )# order by productLine offset #_dataStore.skip# rows fetch next #_dataStore.take# rows only for JSON AUTO, INCLUDE_NULL_VALUES