How to order by column with non-null values first in sql
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;