Problem: I want to fetch all contacts and I need to display contacts which are associated with Account first and then remaining last.
Solution: We can use NULLS FIRST or NULLS LAST keywords along with order by clause in soql while retrieving.
Example:
When you run the below query in Developer Console
SELECT Name,Account.id FROM Contact ORDER BY Account.name ASC NULLS LAST
When you run the below query in Developer Console
SELECT Name,Account.id FROM Contact ORDER BY Account.name ASC NULLS FIRST
Solution: We can use NULLS FIRST or NULLS LAST keywords along with order by clause in soql while retrieving.
Example:
When you run the below query in Developer Console
SELECT Name,Account.id FROM Contact ORDER BY Account.name ASC NULLS LAST
When you run the below query in Developer Console
SELECT Name,Account.id FROM Contact ORDER BY Account.name ASC NULLS FIRST
No comments:
Post a Comment