The NULLS LAST Function in Oracle SQL / PLSQL is used to place the NULL records at the end in the fetched records.
Syntax for using the NULLS LAST function in Oracle SQL / PLSQL is ;
ROW_NUMBER() OVER (ORDER BY column NULLS LAST)
Suppose we have a table named ‘employee’ as shown below:
Now, suppose we want to see the employee_name and commission and also want that the employee records having no commission should be listed LAST then we can achieve the same using NULLS LAST function as:
SELECT employee_name ,commission ,ROW_NUMBER () OVER (ORDER BY commission NULLS LAST) SNO FROM employee;
We will get the following result:
Here we can see that we have successfully fetched employees having no commission LAST in the list.