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

Is there a way to do custom soql order by instead of ASC or DESC?

Asked by Dipesh Bhardwaj May 22, 2023 1.3K views 1 answer
Share

About this question

Is there a way to do custom order by instead of ASC or DESC?

There is a picklist field -> Color__c on a custom object - Products__c - which has following values:

  1. RED

  2. YELLOW

  3. BROWN

If i write a SOQL: Select id, LastOrderDate__c,Color__c from Products__c where Name = 'Shoes' ORDER BY Color__c DESC

its returning YELLOW,RED,BROWN records in this order but i want a custom order by which i prioritise RED over YELLOW, is there way to do a custom order by instead of ASC or DESC?

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.