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

Multi-SQL BMCUNLD card not sorting the result correctly


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aravindunlimited

New User


Joined: 08 May 2006
Posts: 16

PostPosted: Mon Apr 11, 2011 11:34 am
Reply with quote

I am building an unload card for my project. The unload card comprises of three sqls(on 3 similar tables) stacked on one top of the other, as shown below. The primary key of the table is ABC,PQR,XYZ


UNLOAD DIRECT NO
SELECT
ABC,
PQR
XYZ
FROM TABLE1
WHERE XYZ = ‘Y’
ORDER BY
PQR,
XYZ;
SELECT
ABC,
PQR
XYZ
FROM TABLE2
WHERE XYZ = ‘M’
ORDER BY
PQR,
XYZ;
SELECT
ABC,
PQR
XYZ
FROM TABLE3
WHERE XYZ = ‘E’
ORDER BY
PQR,
XYZ;

I was expecting the result to be sorted in the order of PQR, XYZ. But the result is coming in order of primary keys! While I run the unload with individual sqls, I am getting the result sorted in PQR, XYZ order, so I believe the issue is out with the multiple sqls format that I have used.
In such a circumstance how do I achieve the desired sort order?
Back to top
View user's profile Send private message
aravindunlimited

New User


Joined: 08 May 2006
Posts: 16

PostPosted: Mon Apr 11, 2011 12:02 pm
Reply with quote

The above sql is just an example, what I am looking for is a solution to sort the results when there are more than one distinct sqls trying to return same set of columns.
Back to top
View user's profile Send private message
aravindunlimited

New User


Joined: 08 May 2006
Posts: 16

PostPosted: Mon Apr 11, 2011 1:36 pm
Reply with quote

I got a solution, to join the sqls using UNION and keeping the ORDER BY clause at the end of the sql. Issue resolved icon_smile.gif
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts Simplify SORT CARD to combine INREC a... DFSORT/ICETOOL 6
No new posts Sort card to generate the DSN DFSORT/ICETOOL 17
No new posts Sort card to know that creation date ... DFSORT/ICETOOL 10
No new posts COBOL sorting, with input GDG base COBOL Programming 7
Search our Forums:


Back to Top