Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to sort SOQL with 2 fields?

Asked by Diane Carr Aug 28, 2023 1.8K views 1 answer
Share

About this question

If I have to make a SOQL Query with the animals sorted by CreatedDate DESC and Zoo Id, wherein I have object Animal__c and field ZooId, then how can I sort this using SOQL orderby instead of using GROUP BY? My target result is:

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

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.