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 ) ?

  • It would help a bit more if you showed us the query, what data you're querying, and what is the problem you want to solve. Do you want to do paging? Perhaps you can find a different field to page on? Perhaps unique names?
    – mkorman
    Dec 3, 2015 at 12:33
  • @mkorman, thanks I was tried to find a generic way to solve this, as we cannot base on "CreatedDate" field, and seem I got the answers below.
    – liratanak
    Dec 3, 2015 at 15:34

1 Answer 1


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
  • What I was thinking at that time ... :-D, thanks ... It's worked.
    – liratanak
    Dec 3, 2015 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .