SOQL ORDER BY – 2 Fields?

I’m looking for a way to achieve this in SOQL:

https://stackoverflow.com/questions/8532599/need-to-perform-order-by-twice

I’d like to order by the Priority field on Case, otherwise order by Age of Case

So for example:

Priority - Age of Case

Urgent , 5
Urgent , 4
High   , 7
High   , 6
Low    , 17
Low    , 10
Low    , 5

Hope this makes sense.

Answer

You need to separate fields with comma like this :

ORDER BY YOURFIELD1, YOURFIELD2

See the documentation :
http://developer.force.com/cookbook/recipe/sorting-query-results

Attribution
Source : Link , Question Author : Community , Answer Author : SF_user

Leave a Comment