Null value and analytical functions

Null values can be handled with NULLS First and NULLS Last options. NULLS First is the default option.


SQL> select ename, sal, DENSE_RANK() over (order by sal NULLS FIRST) toprank
  2  from emp
  3  order by sal;

ENAME             SAL    TOPRANK
---------- ---------- ----------
MARTIN           1250          2
WARD             1250          2
ADAMS            1500          3
TURNER           1500          3
CLARK            2850          4
BLAKE            2850          4
JONES            2975          5
KING             3000          6
SCOTT            3000          6
SMITH                          1
ALLEN                          1

11 rows selected.

SQL>
SQL> select ename, sal, DENSE_RANK() over (order by sal NULLS LAST) toprank
  2  from emp
  3  order by sal;

ENAME             SAL    TOPRANK
---------- ---------- ----------
WARD             1250          1
MARTIN           1250          1
TURNER           1500          2
ADAMS            1500          2
BLAKE            2850          3
CLARK            2850          3
JONES            2975          4
SCOTT            3000          5
KING             3000          5
SMITH                          6
ALLEN                          6

11 rows selected.

SQL>
Home »
Oracle »
Analytical Functions » 

Null_Values:
  1. Null value and analytical functions
  2. Ignore the Null value in analytical functions
  3. Handle Null values with NVL function and use that value in analytical functions
  4. NVL and NULLS Last option together
Related: