I know TOP can return first 10% of row results, but how would I then get the next 10%? I am trying to break up a query that crashes due to insufficient memory (java.lang.OutOfMemoryError), and want to return the first 10% of results, then edit it so it returns the next 10%, and so on. I am using SQL Anywhere 12.


1 Answer 1


One idea ...

If the first batch of rows is ordered by a column(s), use the max/last line as an additional 'where' clause in the 2nd query.

For example, let's say the 1st query pulled back the first 100 IDs (ordered by ID): ID = 1..100

For the 2nd second query you could add an additional 'where' clause to (effectively) skip those first 100 IDs, eg: select top 100 ID from ... where ... and ID >100 ... order by ID.

  • You just gave me an idea. The rows are not ordered by a column but there is a date for each row. I could try breaking the results up by a date range. Thanks!
    – KAE
    Apr 7, 2020 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.