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 Why TS/OP would Not contact site supp... RahulG31 All Other Mainframe Topics 2 Wed Mar 22, 2017 7:46 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am


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