RANK and DENSE_RANK

RANK() : function always returns sequential order for each record.
DENSE_RANK() : It returns continuous order for each record.

Preview

SELECT empno,
       deptno,
       sal,
       mgr,
       RANK () OVER (PARTITION BY deptno ORDER BY sal) "rank",
       DENSE_RANK() OVER (PARTITION BY deptno ORDER BY sal) "dense rank"    
  FROM emp;

Preview


comments powered by Disqus