You need to sign in to do that
Don't have an account?
Developer_shaan
Issue sorting with null values
Hello,
Using soql query i am able to sort the records. The records are being sorted based on a field in asc or descending order.
But i am not able to sort the null values.(I.e) when used ascending order the null values should be at the top and when teh order is desc the null values should come at last.
Please let me know if any one has soln for this.
Thanks
shaan
As a rule the null values will always come at the top whether you are sorting in ascending or decending order a way to solve this is to have a a dummy field corresponding to the field on which you are sorting say is a field- Mailing Street is of type text. Then try using a dummy_Mailing _Street__c as a formula field which when the field is null assign it the smallest possible text value say 'a ' and then in your query sort on this dummy field.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thansk for the reply.
But here i need to sort based on particular fields .
I got a solution for this .. the records are validated not to be null.
When issuing an ORDER BY you can elect to have the NULLs first or last.
http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_soql_select_orderby.htm
You can use SOQL like this.