http://it.toolbox.com/blogs/meditations-on-db2/order-by-showing-nulls-first-53111 also backs up that ASC + LAST and DESC + FIRST are the valid combinations...
In DB2, the ORDER BY ... ASC clause is the same as ASC NULLS LAST as well as ORDER BY ... DESC is the same as DESC NULLS FIRST. The combinations ASC NULLS FIRST or DESC NULLS LAST are not supported.
This is so, because DB2 considers null values as greater than any other values, which explains why nulls go "to the bottom" in a sort operation.
So I think what I wrote is still the best, but I need to invert the "allowed combos". So what we will have is this:
-
ASC + NULLS FIRST -> case statement...
-
ASC + NULLS LAST -> just drop the NULLS LAST from sql fragment
-
DESC + NULLS FIRST -> just drop the NULLS FIRST from sql fragment
-
DESC + NULLS LAST -> case statement
|