I need some assistance with creating a query that will get all the records that correspond to the first 100 orders. For example the table looks something like this:

Order Number

I know I can use GROUP BY grab the 100 orders but I don't know how I would then get all of the records within each order. I thought of then querying each order but that would exceed the governor limit(and is probably not a good idea anyway.

This code is already live and wasn't supposed to be more than a 100 records a day but just got a batch of over 100 this hour and broke my code... ANY assistance would be greatly appreciated!

  • I am not really sure about your usecase but can't you use inner query to get the related records. e.g. Get all the contacts associated with the first 100 Accounts. [Select Id, name, (Select Id, Name FROM Contacts) FROM Account LIMIT 100];
    – Kalpana
    May 14, 2021 at 13:33
  • You should edit your post with a description of what the use case is. What is the code doing? Then we may be able to provide more specific feedback. May 14, 2021 at 14:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.