I am trying to query records from big object in a list, using the following query

Select Edit_Date__c ,CreatedDate,Field__c ,Loan_ID__c ,New_Value__c ,Old_Value__c ,User__c, System_Updates__c, Audit_ID__c FROM Loan_Audit__b limit 1000

I want to return most recent created records in the list using the above query. The above query is not allowing me to add ORDER BY CreatedDate DESC so that i can sort the records as the latest created records appers first.Please provide me some solution or any workarounds to sort this records.

  • 1
    Can you post the error message you are getting? – Atlas Can Nov 13 at 10:28
  • 1
    field 'CreatedDate' can not be sorted in a query call I am getting this error when i tried this query Select Edit_Date__c ,CreatedDate,Field__c ,Loan_ID__c ,New_Value__c ,Old_Value__c ,User__c, System_Updates__c, Audit_ID__c FROM Loan_Audit__b order by CreatedDate limit 1000; – Tushar Shinde Nov 13 at 10:30
  • 1
    Have you tried using Edit_Date__c for sorting, to see if it's supported. – Atlas Can Nov 13 at 10:31
  • 1
    yes i have tried order by with all the fields that i have in big object – Tushar Shinde Nov 13 at 10:32
  • 1
    AFAIK, maybe it's because the date field is not indexed, or you need to use as an async SOQL or you need to check if that aggregate function is supported. – Atlas Can Nov 13 at 10:41

You need to run your query as async SOQL and index the field you are querying. Aggregate functions are only supported then.

Implementation guide


We can use Order By on the big object field, but this field should be a part of index and also it should be the first index key.

We can make any 5 field as index in big object. But the field using which you want to sort Order By the records in query should be the first index key field.

I have used the following query;

SELECT  CreatedById, CreatedDate, SystemModstamp, AlternateNumber__c, Blockname__c FROM BObject__b order by Blockname__c 

Here in this query, Blockname__c is my first index field.

Your Answer

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

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