I need to implement pagination for my union query, but I get error "Msg 102, Level 15, State 1, Line 14 Incorrect syntax near ')'.". I followed example I found from this link.
select *
from (select Id,
row_number() OVER (order by Id asc) as RowNumber
from (select Id
from (select Id
from Table1) as table1
union all
select Id
from (select Id
from Table2) as table2)) as t Derived
WHERE RowNumber > 5
and RowNumber <= 10