View previous topic :: View next topic |
Author |
Message |
anu.k Beginner
Joined: 09 Nov 2006 Posts: 6 Topics: 4
|
Posted: Tue Jul 13, 2010 3:12 pm Post subject: Sort sum multiple rows & update a new column |
|
|
Hi,
My requirement is to capture yearly amount based on monthly figures. Right now, the year-amt is 0. Need to sum-up and capture yearly amount as of that month.
Key is 1-132 bytes.
Code: |
DATE - X(10)
Account details - X(122)
Month amount - S9(16)V99
Year amount - S9(10)V99
|
Sample input: Code: |
Date Account details month-amt year-amt
------------ ---------------- ------------- -----------
2010-01-01 ABC 100 0
2010-01-01 DEF 400 0
2010-02-01 ABC 500 0
2010-03-01 ABC 0 0
2010-03-01 DEF 100 0
2010-04-01 ABC 50 0
2010-05-01 ABC 200 0
|
Output should be like : Code: |
Date Account details month-amt year-amt
---------- ---------------- ------------- -----------
2010-01-01 ABC 100 100
2010-01-01 DEF 400 400
2010-02-01 ABC 500 600
2010-03-01 ABC 0 600
2010-03-01 DEF 100 700
2010-04-01 ABC 50 650
2010-05-01 ABC 200 850
|
Please advice with some SORT solution.
Thanks,
Anu |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
Posted: Tue Jul 13, 2010 4:22 pm Post subject: |
|
|
anu.k,
Something Doesn't make sense. How did the record
2010-03-01 DEF 100 get 700 as total? Shouldn't it be 500??
Also if you are summing a 18 byte field , how can you expect it to fit in a 12 byte field for year amount? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|