Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

first in frist out

hi  can anyone help me

i have a table like below

type    id      date                amount

rec      1      1/4/2015            5000

rec       2     1/5/2015            6000

pay      1      1/6/2015           2000

rec      3       1/7/2015           1000

pay      2       1/8/2015            8000

i need o/p like this

recID  pay ID   amount

1          1             2000

1           2             3000

2           2             5000

14 Replies
MK_QSL
MVP
MVP

Where is recID nad pay ID in your input Table? Can you clarify little more on your requirement?

nareshthavidishetty
Creator III
Creator III
Author

hi manish

its in type recid

                payid

MK_QSL
MVP
MVP

Yes but need to understand the logic how you are getting the output table !

nareshthavidishetty
Creator III
Creator III
Author

i want payment id against received id

case1 received   amount , 5000   but payment     is 2000 so u left with 3000 this is for id 1 that's y the received id and payment id is 1

                                       8000 need to be payed but u got 3000 in id 1 so go for next id 2 there u received 6000 and payed rest 5000 left with 1000 remaining two entries will be

recid    paymentid   amount

1          2                3000

2           2               5000

















   

MK_QSL
MVP
MVP

i need o/p like this

recID  pay ID   amount

1          1             2000

1           2             3000

2           2             5000

The 1 ,1 have 2000 is that correct?

nareshthavidishetty
Creator III
Creator III
Author

yes correct what u said

MK_QSL
MVP
MVP

I am confused... as per your explanation..

type    id      date                amount

rec      1      1/4/2015            5000

rec       2     1/5/2015            6000

pay      1      1/6/2015           2000

rec      3       1/7/2015           1000

pay      2       1/8/2015            8000

rec ID     pay ID       amount Left

1               1                    5000 - 2000 = 3000

1               2                      3000 + 6000 - 8000 = 1000

How you are getting 2000, 3000, 5000?

Sorry but until the logic and your expected output is not clear for me, can't work on this script...!

nareshthavidishetty
Creator III
Creator III
Author

Hi Manish,

Let us consider this to be a transaction.Where my payment amount is being subtracted from the receiving amount.

If there is a remainder in the amount subtracted, then we use it to subtract the payment amount of the second ID (2). We subtract the payment amount from remainder amount of ID '1'.

For the payment amount that remains from subtraction from the remainder amount of ID '1', then we make use of the received amount of ID '2' to subtract the remaining payment amount of ID '2'. and so on......

Let me know if you need

sasiparupudi1
Master III
Master III

please post your data file