Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SUM FIELDS= on Multiple keys

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Wed Oct 03, 2007 6:30 pm    Post subject: SUM FIELDS= on Multiple keys
Reply with quote

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
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Oct 03, 2007 6:36 pm    Post subject:
Reply with quote

Paray,

Sort on both the fields (key 1 & Key2) and SUM on key3.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 03, 2007 8:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Oct 03, 2007 9:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Thu Oct 04, 2007 3:46 pm    Post subject: Reply to: SUM FIELDS= on Multiple keys
Reply with quote

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
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Thu Oct 04, 2007 7:49 pm    Post subject:
Reply with quote

Ah, totally missed that in the original post. Thanks.
Back to top
View user's profile Send private message
paray2x

New User


Joined: 28 Dec 2005
Posts: 21

PostPosted: Thu Oct 04, 2007 10:31 pm    Post subject:
Reply with quote

Hi All,

thanks for ur help. I got the required output
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Joinkeys with duplicated keys juares castro SYNCSORT 19 Fri Sep 23, 2016 5:58 am
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us