Joined: 20 Jun 2005 Posts: 86 Location: Chennai, India
My site uses Syncsort as primary sort product, so I would appreciate if you could give me a solution using syncsort.
Here is a sample I/P and O/P what I wish to achieve. I gave it a shot but couldn't get it through.
I/P: I have 3 fields - policy number, date and amount
I need to sort this such that I have only one record for each policy in output, and the record being the one with latest date; in addition, if multiple records are present with latest date for a policy, I need the sum of amounts present in those records for that policy.
My output should be like this:
Code:
polX 10/23/06 400
polY 10/25/06 200
where the amount for polX is the addition of 100 and 300 present in records 1 & 3 in the I/P. Is it feasible to construct this in single step? Or is this feasible in multiple steps?
I am using SYNCSORT, but if this is not feasible, I will see if I could push DFSORT solution in for this. Thanks.
Joined: 20 Jun 2005 Posts: 86 Location: Chennai, India
Jerry,
Thanks for the quick replies. But your second sort step sums up the values present in all the records for a particular policy. I don't need the sum of all of them; I need the sum total of values present only in the records with latest dates for a policy. Could you please see the example in my previous posting again?
Here is the output from your steps for my input:
Oops. Thanks for correcting me. You would have to include a sort step to remove the duplicates (using sum fields = none) after the first step to sort it in descending order.