Oracle: Simulating Dense_Rank Analytical Functions (Manual Dense_Rank)

ORIGINAL QUERY
select
    empno,
    ename,
    deptno,
    sal,
    dense_rank() over(partition by deptno order by sal) drnk
from
    scott.emp

--------------------------------------------------------
SIMULATED QUERY
select
    empno,
    ename,
    deptno,
    sal,
    (select count(distinct sal) from scott.emp a where a.deptno=b.deptno and a.sal <= b.sal) drnk
from
    scott.emp b
order by
    deptno, sal


OUTPUT
 






















Related Links:
- Oracle: Getting Cumulative Sum (Running Total) Using Analytical Functions
- Oracle: Getting Simulated Cumulative Sum (Running Total)
- Oracle: Simulate Lead Analytical Function (Manual Lead)
- Oracle: Simulating Rank Analytical Functions (Manual Rank)
- Oracle: Rank, Dense_Rank, Row_Number Analytic Functions
- FIRST_VALUE and LAST_VALUE with Windowing Clause


No comments:

Post a Comment