I have read Workaround for Offset 2000 limit on SOQL Query and sfdcfox's https://salesforce.stackexchange.com/a/22643/14880 does works for most cases.
BUT What if some records have same CreatedDate ( created via mass operation ) ?
I have read Workaround for Offset 2000 limit on SOQL Query and sfdcfox's https://salesforce.stackexchange.com/a/22643/14880 does works for most cases.
BUT What if some records have same CreatedDate ( created via mass operation ) ?
In that scenario best approach would be to use ID, as they are never unique.
SELECT Id, Name, CreatedDate FROM Account ORDER BY ID LIMIT 2000
At this point, you'll get your next 2000 records. You can rinse and repeat as necessary. If you want to go back a page, just reverse the order (but you'll also have to reverse the results):
SELECT Id, Name, CreatedDate FROM Account WHERE ID > "Last-Returned-ID" ORDER BY ID LIMIT 2000