Using DENSE RANK
We have RANK transformation to calculate RANK based on Some Measure .If we need to calculate Dense rank then we have two approches
- Using Source Qualifier Override
- Using Sorter and Expression ( using variable port )
Let us see how to do using Source Qualifier Override
Process :
Step 1: Create Source Table & Data
- We can use Scott Schema EMP table
- Import table using source analyzer
Step 2: Create Target Table
- Create target table in target database
CREATE TABLE TGT_DENSE_RANK
( EMPNO NUMBER(4,0),
ENAME VARCHAR2(10 BYTE),
SAL NUMBER(7,2),
RANK NUMBER,
DENSERANK NUMBER
)
- Import table using Target Designer
Step 3: Create mapping with transformations
- Create a mapping with the name m_dense_rank
- Drag and drop source and target into work area
- Double click on source qualifier → Go to PORTS tab → Delete and rename Columns as shown below
- Connect Rank and DenseRank ports as shown .Do not worry we are not reall going to pass comm and deptno to rank and denserank
- Click on Properties tab → SQL QUERY
- Provide below sql query
SELECT EMPNO,
ENAME,
SAL,
RANK () OVER (ORDER BY SAL DESC) RANK,
DENSE_RANK () OVER (ORDER BY SAL DESC) DENSERANK
FROM EMP
|
- Click on Validate → click on OK → Click on OK
- connect to target
- Save the Mapping
Step 4: Create Workflow and Session
- Create workflow and session as shown below
- Double click on session task provide source and target connection accordingly
- Save the workflow
Step 5: Run workflow and Observe output
- Select Start task → click on run
- observe target data
- Observe target table output
No comments:
Post a Comment