IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

GROUP BY Using DFSORT/ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Wed Jun 02, 2010 10:43 pm
Reply with quote

Hello All,

I have a file which has a LRECL of 10 and contains date values. Looks as follows:

2009-05-31
2009-05-31
2009-05-31
2008-05-31
2008-05-31
2006-05-31

I want to acheive the function of GROUP BY in SQL using SORT and get the unique date values along with the number of occurence. The output should look like:

2009-05-313
2008-05-312
2006-05-311

Kindly let me know if any of you know of how to accomplish the same or any other thread which discusses a similar topic

Thanks in advance.

Arvind
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 02, 2010 11:06 pm
Reply with quote

rarvins,

Assuming that your input is already sorted on date field, the following JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
2009-05-31                                               
2009-05-31                                               
2009-05-31                                               
2008-05-31                                               
2008-05-31                                               
2006-05-31                                               
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  OUTFIL REMOVECC,NODETAIL,BUILD=(15X),                           
  SECTIONS=(1,10,TRAILER3=(1,10,X,COUNT=(M10,LENGTH=4)))
//*


the output from this is
Code:

2009-05-31    3
2008-05-31    2
2006-05-31    1
Back to top
View user's profile Send private message
rarvins

New User


Joined: 24 Jan 2007
Posts: 59
Location: Texas

PostPosted: Thu Jun 03, 2010 3:26 am
Reply with quote

Thanks a lot SKolusu... it worked
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
Search our Forums:

Back to Top