Thursday 23 May 2013


Sorting Query Results

Results of a query can be sorted by up to 32 fields in ascending (ASC, the default) or
descending (DESC) order. Sorting is not case-sensitive, and nulls appear first unless otherwise
specified (NULLS LAST). Multi-select picklists, long text areas, and reference type
fields cannot be used as sort fields.The SOQL query in Listing 5-28 returns records first
in ascending order by Type, and then in descending order by LastModifiedDate.

Listing 5-28 SOQL Statement with Sort Fields

SELECT Name, Type, AnnualRevenue FROM Account ORDER BY Type, LastModifiedDate DESC

No comments:

Post a Comment