I have the object Animal__c, with the field ZooId.
I want to make an SOQL Query with the animals sorted by CreatedDate DESC and Zoo Id.
Now the list is:
- Animal 0 ZooId 5 CreatedDate Yesterday
- Animal 1 ZooId 4 CreatedDate Today
- Animal 2 ZooId 4 CreatedDate Yesterday
- Animal 3 ZooId 5 CreatedDate Today
- Animal 4 ZooId 5 CreatedDate Yesterday
SELECT Id, CreatedDate, ZooId ORDER BY CreatedDate DESC, ZooId
- Animal 3 ZooId 5 CreatedDate Today
- Animal 1 ZooId 4 CreatedDate Today
- Animal 0 ZooId 5 CreatedDate Yesterday
- Animal 4 ZooId 5 CreatedDate Yesterday
- Animal 2 ZooId 4 CreatedDate Yesterday
And I want this:
- Animal 3 ZooId 5 CreatedDate Today
- Animal 0 ZooId 5 CreatedDate Yesterday
- Animal 4 ZooId 5 CreatedDate Yesterday
- Animal 1 ZooId 4 CreatedDate Today
- Animal 2 ZooId 4 CreatedDate Yesterday
Is that possible?? Sorting like this With an SOQL Query?? Without using GROUP BY because I am not interested in aggregate results. My priority is **
- first sorting by CreatingDate.
- second sorting by ZooId.
**
ZooId
, then byCreatedDate