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
 

 

GROUP BY Using DFSORT/ICETOOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: GROUP BY Using DFSORT/ICETOOL
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    Post subject: Reply to: GROUP BY Using DFSORT/ICETOOL
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Using ICETOOL, how we can seperate th... bshkris SYNCSORT 5 Tue May 09, 2017 8:33 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Need Help with : IFTHEN(WHEN=GROUP) Sumanta_89 DFSORT/ICETOOL 1 Wed Apr 19, 2017 5:23 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am


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