I need to write a sql statement to select all users ordered by lastname, firstname. This is the part I know how to do :) What I don\'t know how to do is to order by non-nu
See Sort Values Ascending But NULLS Last
basically
SELECT *
FROM @Temp
ORDER BY CASE WHEN LastName IS NULL THEN 1 ELSE 0 END, LastName
ORDER BY CASE WHEN name IS NULL THEN 1 ELSE 0 END, name;
Nowadays the
IIF ( boolean_expression, true_value, false_value )
will suit too.
ORDER BY IIF(name IS NULL, 1, 0), name