Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top