You need to sign in to do that
Don't have an account?
Nikki_tcs
Sorting in asc/ desc in soql
Hi,
How can i sort the list of values (ascending /descending) using soql query?
SELECT Id, CommentBody, CreatedById, createdBy.communityNickname, CreatedDate, IdeaId
FROM IdeaComment
WHERE IdeaId in :ideaIds
AND createdById = :createdById];
Can anyone provide the syntax?
Thanks,
Nik
Here you go man!
SELECT Id, FirstName FROM Lead ORDER BY Name DESC LIMIT 10
Remove the limit clause if you want to query all.
Gaston.
All Answers
Actually, I think you would want to use the "order by" keyword.
somthing like this:
select id,name,billingcity from Account order by billingcity asc
RTFM, use an "order by" clause.
One caveat that miight not be listed in the manual. If you are sorting picklist fields, the will not sort alphabetically. They will sort based on the order defined in the picklist.
Here you go man!
SELECT Id, FirstName FROM Lead ORDER BY Name DESC LIMIT 10
Remove the limit clause if you want to query all.
Gaston.