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
 

 

Multi-SQL BMCUNLD card not sorting the result correctly

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Multi-SQL BMCUNLD card not sorting the result correctly
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    Post subject: Reply to: Multi-SQL BMCUNLD card not sorting the result corr
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    Post subject: Reply to: Multi-SQL BMCUNLD card not sorting the result corr
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm


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