View previous topic :: View next topic
|
Author |
Message |
paray2x
New User
Joined: 28 Dec 2005 Posts: 21
|
|
|
|
Hi All,
Can u suggest a method on how to SUM numeric fields for more than one key?
Example:
Input
Key1 key2 value
------ ------- -------
AAA KKK 1
BBB JJJ 1
AAA KKK 1
BBB JJJ 1
BBB III 1
AAA III 1
The output I expect is
Key1 key2 value
------ ------- -------
AAA KKK 2
AAA III 1
BBB JJJ 2
BBB III 1
Pls suggest a solution using SYNCSORT/SYNCTOOL.
Thanks |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Paray,
Sort on both the fields (key 1 & Key2) and SUM on key3. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I'd suggest that an answer like
Quote: |
Sort on both the fields (key 1 & Key2) and SUM on key3. |
should be clarified by the sort control statememts that would meet the posted requirement. |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Assuming data is FB, and KEY1 is position 1-3, KEY2 is position 5-7, and VALUE is in position 9, try this:
Code: |
//SYSIN DD *
SORT FIELDS=(1,3,CH,A,5,3,CH,A)
SUM FIELDS=(9,1,ZD)
|
|
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
Hi Alissa,
The expected output requires K's and I's to be in descending order within first key.
Code: |
Key1 key2 value
------ ------- -------
AAA KKK 2
AAA III 1
BBB JJJ 2
BBB III 1 |
So, the correct sort card would be :
//SYSIN DD *
SORT FIELDS=(1,3,CH,A,5,3,CH,D)
SUM FIELDS=(9,1,ZD)
Thanks,
Ajay |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Ah, totally missed that in the original post. Thanks. |
|
Back to top |
|
|
paray2x
New User
Joined: 28 Dec 2005 Posts: 21
|
|
|
|
Hi All,
thanks for ur help. I got the required output |
|
Back to top |
|
|
|