Find Rank Based On Salary

How to find rank based on salaries?
Input
------
sal
5000
5000
4000
3000
Output
---------
Sal Rank
5000 1
5000 1
4000 2
3000 3

Showing Answers 1 - 3 of 3 Answers

venkat

  • Mar 28th, 2016
 

use dense_rank() SQL function and use Sort stage.

  Was this answer useful?  Yes

Ram

  • Mar 28th, 2016
 

Src-->sort(desc)-->Trnsfrm(3 stage variables & generate Rank col) --> trg.
Transform Derivation for Rank column:
Initialize Stgv1,Stgv2,Stgv3=0
stgv1=Sal
stgv2=>if stgv1=stgv3 then stgv2 else stgv2+1
stgv3=stgv1

  Was this answer useful?  Yes

Reddy

  • Apr 1st, 2016
 

3 stage variables:
sal : stgVar1
((sal< >presal and sal > presal) or(sal=presal)) then 1 else 0 : StgVar2
stgVar1 :presal
1 :Rank
if StgVar2=1 then Rank else Rank++ :RankVal

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions