I\'m using mySQL. I have to order names of Contacts by Lastname but in the case that there is no last name, I order by firstname.
This looks like:
OR
ORDER BY CASE WHEN LName is null THEN FName ELSE LName END
more here