|
View previous topic :: View next topic
|
| Author |
Message |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Hello Team,
I have to convert beloq sql query to corresponding sort so is it possible to do it?
| Code: |
SELECT B.name
, A.userid
, A.number
FROM name1 A
, userid1 B
, number1 C
WHERE
A.uu <> 0
AND A.char = B.char
AND A.number = B.number
AND A.aset = C.aset |
Below are the unload files and corresponding offsets,
1)name1
userid=1:10
number=11:10
uu=31:5
char=40:5
aset=55:8
2)userid1
char=10:5
number=22:10
Name=30:10
3)number1
aset=11:8 |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, we don't particularly care about the SQL.
Define your requirement, fully, in plain language, and show sample data which covers the possible combinations you want. LRECL and RECFM of all files. |
|
| Back to top |
|
 |
gylbharat
Active Member
.jpg)
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
| Join 2 files at a time... then join the result with the 3rd file. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
How are you going to get the data out of the table so the sort can access it?
If there are millions and millions of rows in the tables, this does not sound like an acceptable approach . . . |
|
| Back to top |
|
 |
knickraj Warnings : 1 New User

Joined: 11 Jun 2007 Posts: 50 Location: Euro
|
|
|
|
Asumming you unload the table to 3 datasets A,B,C
can be done in 2 steps using joinkeys
============================
1 step
======
join file A and C on asset
use include/Omit cond for file A to eliminate in the joinkey subtask.
Get all the fields of file A and use in step 2
2 step
======
join file A(from step1) and B on the required keys
| Code: |
A.char = B.char AND
A.number = B.number |
and using reformat fields get the data which you want. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
knickraj,
What do you mean by "eliminate the joinkey subtask"? It'd be a cool trick if you can do it, but I suspect you mean something else, so, what?
EDIT:
Sorry knickraj, didn't notice the crucial word "in".
Thanks dbz. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Rohit Umarjikar,
Your USERID file have overlapping fields. If the number field starts at pos 22 for a length of 10 bytes you cannot have the Name field start at position 30. I assumed that the name field in userid file starts at pos 35.
Use the following DFSORT JCL
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=Your NAME1 fileA,DISP=SHR
//INB DD DSN=Your NUMBER1 fileC,DISP=SHR
//SORTOUT DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(55,8,A)
JOINKEYS F2=INB,FIELDS=(11,8,A)
REFORMAT FIELDS=(F1:1,62)
//*
//JNF1CNTL DD *
OMIT COND=(31,5,ZD,EQ,0)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=&&TEMP,DISP=SHR
//INB DD DSN=Your USERID1 fileB,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(40,5,A,11,10,A)
JOINKEYS F2=INB,FIELDS=(10,5,A,22,10,A)
REFORMAT FIELDS=(F2:35,10,F1:1,20)
//* |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
@Dick:
Your are correct, but I do have the unload files for these tables and the reason I am trying it to convert the SQLs to SORT is beacuse of more CPU time is being taken by these SQLs in batch.
@Skolusu:
Thanks for your support as I always get, I will try this out.
@Rest All:
Thanks a lot for your views. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
@Skolusu,
| Code: |
SELECT Count (Distinct B.name )
, Count (Distinct A.userid)
, Count (Distinct A.number)
FROM name1 A
, userid1 B
, number1 C
WHERE
A.uu <> 0
AND A.char = B.char
AND A.number = B.number
AND A.aset = C.aset |
This is the query and the one u gave up is working fine can you suggest me to modify the SORT? |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Skolusu already gave you a sort solution. What else is needed? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Rohit Umarjikar wrote: |
@Skolusu,
This is the query and the one u gave up is working fine can you suggest me to modify the SORT? |
Rohit Umarjikar,
Is there an end to your queries ? I provided the frame work for the matching , now YOU can/have to expand it to get to the counts. Just because I tend to provide complete solutions , doesn't mean that you can get your work done by me. Look up the reporting features TRAILER , SECTIONS and COUNT keywords.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Thanks Skolusu...I will go thru them. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|