order by emailAddress with result as ( select distinct emailTo as emailAddress from tbl_WRK_Emails with (nolock) where ownerId = and ownerType = ) select count(*) over() as fseRowCount, emailAddress from result where emailAddress = where #applyFilter( attributes.dataStore.filter )# #_orderBy# offset #attributes.dataStore.skip# rows fetch next #attributes.dataStore.take# rows only for json path, include_null_values