I have a big query to make and then I convert to JSON so I get OutofMemory Exception in JAVA during my conversion. What I'm trying to achieve is split the query dynamically calling it multiple time.
SELECT ROWS x/10 multiply by (SELECT COUNT(*) FROM myquery) to
y/10 multiply by (SELECT COUNT(*) FROM myquery)
You need a field to order your rows call it
order_field. And use the analytic function NTILE(10) to create 10 groups
Then pass a variable
@YourPage to indicate what page you want
SELECT * FROM ( SELECT *, NTILE(10) OVER (ORDER BY order_field) as page_number FROM yourTable ) T WHERE T.page_number = @YourPage