function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shubham SengarShubham Sengar 

SOQL Problem 7

Show all the Account records in alphabetical order by first name, sorted in descending order, with 

accounts that have null names appearing last:??
William TranWilliam Tran
Accounts don't have first name unless you create a custom first name field.

Are you referring to contacts?

Hi Shubham,

Whether you are reffering Account or Contact, you just need to put 'order by Name DESC' in your query like:

For Account:
Select Id, Name from Account order by Name DESC

For Contact
Select Id, FirstName from Contact order by FirstName DESC

If this help, please mark as best answer so will help others also.

Amit Chaudhary 8Amit Chaudhary 8
Hi Shubham,

Please try below query. I hope that will help you
Select Id, FirstName from Contact order by FirstName DESC NULLS LAST
Please check below post for some sample

Please let us know if this will help you

Amit Chaudhary