The NULLS FIRST Function in Oracle SQL / PLSQL is used to place the NULL records at the beginning in the fetched records.
Syntax for using the NULLS FIRST function in Oracle SQL / PLSQL is ;
ROW_NUMBER() OVER (ORDER BY column NULLS FIRST)
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 employees having no commission should be listed first then we can achieve the same using NULLS FIRST function as:
,ROW_NUMBER () OVER (ORDER BY commission NULLS FIRST) SNO
We will get the following result:
Here we can see that we have successfully fetched employees having no commission first in the list.