[Sqlserver ]:
Sqlserver considers null to be the smallest.
Sort in ascending order: The null value is ranked first by default.
Order by case when col is null then 1 else 0 end, Col
Sort in descending order: The null value is ranked last by default.
Order by case when col is null then 0 else 1 end, col DESC
[Oracle ]:
Oracle considers null to be the largest.
Sort in ascending order,By default, the null value is placed behind it.
Sort in descending order,By default, the null value is first.
There are several ways to change this situation:
(1) Use the nvl function or decode function to convert null to a specific value.
(2) Use Case syntax to convert null to a specific value (later than Oracle9i. Similar to sqlserver ):
Order by (Case mycol when null then 'Beijing drioker' else mycol end)
(3) Use nulls first or nulls last syntax.
This is Oracle's syntax for sorting null values.
Nulls first: Place null at the top. For example, select * From mytb order by mycol nulls first
Null last: the last line of null. For example, select * From mytb order by mycol nulls last
If you want to sort the columns containing null according to your own wishes, you can perform the preceding operations.