Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9236

Re: Need a Logic for balance

$
0
0

hi Rajesh,

 

I was on vacation for one week

 

i tried as per your above logic

 

for new_balance field upto 3 ranks i am getting correct but for rank 4 i am not getting as expected

 

i am using  balance - PAID_AMOUNT * (RANK -1)

 

 

for example

 

Input

 

balance  paid_amount rank ssn

1320        0                  1       111111111

1320        17                 2      111111111

1320        17                 3      111111111

1320         4                  4      111111111

 

Output

 

 

balance  paid_amount rank ssn                new_balance

1320        0                  1       111111111   1320

1320        17                 2      111111111   1303

1320        17                 3      111111111    1286

1320         4                  4      111111111    1308(should be 1284)

 

 

For the balance field, for rank 2 i am getting null

 

Using ifthenelse( RANK = 1, balance, previous_row_value(new_balance))

 

output getting as

 

 

balance  paid_amount rank ssn                new_balance

1320        0                  1       111111111   1320

null         17                 2      111111111   1303

1303        17                 3      111111111    1286

1286         4                  4      111111111    1308

 

any suggesion please

 

Thanks

Madhu


Viewing all articles
Browse latest Browse all 9236

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>