Oracle sorting of null values: 1. Oracle determines that NULL is the maximum value by default when Order by is used, therefore, if ASC is in ascending order, it is at the end, and DESC is in descending order. 2. When the input parameter is null, use the nvl function www.2cto.com nvl to convert it to a specified value, for example, nvl (employee_name, 'zhang san') indicates that when employee_name is empty, 'zhang san' is returned. If not empty, the return value is employee_name. This function allows you to customize the null sorting position. 3. the decode function is more powerful than the nvl function. It can also convert an input parameter to a specified value when it is null, such as decode (employee_name, null, 'zhangsan ', employee_name) indicates that when the value of employee_name is null, 'zhang san' is returned. If the value is not null, the return value is employee_name. This function can be used to customize the null sorting position. 4. The case syntax is supported after Oracle 9i. It is a flexible syntax, and www.2cto.com can also be used in sorting, for example: select * from employee order by (case employee_name when null then 'zhang san' else employee_name www.2cto.com end) indicates that when employee_name is null, 'zhang san' is returned ', if it is not null, the return value is "employee_name". The case syntax can also be used to customize the null sorting position. 5. Use nulls first or nulls last syntax Nulls first and nulls last are the syntaxes supported by Oracle Order by. If the expression Nulls first is specified in Order by, the records with null values are ranked first. (whether asc or desc) if the expression Nulls last is specified in Order by, the records with null values will be placed at the end (whether asc or desc) use the syntax www.2cto.com to always put nulls at the beginning select * from zl_cbqc order by cb_ld nulls first // cb_ld is null always at the beginning put nulls always at the end select * from zl_cbqc order by cb_ld desc nulls last