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
 

 

Order by query is not giving the appropriate results

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
adarsh444

New User


Joined: 02 Nov 2006
Posts: 17

PostPosted: Sat Nov 11, 2006 3:07 pm    Post subject: Order by query is not giving the appropriate results
Reply with quote

The below query is not giving the appropriate results in my program.
Is order by with fetch first row valid.?


SELECT DATE_1,
DATE_2,
FROM TABLE001
WHERE ACCT_ID = '1'
AND ACCT_NBR = '13244'
AND SUR_NAME = (
SELECT FAC_NAME
FROM TABLE002
WHERE ACCT_ID = '0256'
)
ORDER BY DATE_3 DESC, TIME_3 DESC
FETCH FIRST ROW ONLY
Back to top
View user's profile Send private message

BuildersHeaven

New User


Joined: 17 Apr 2006
Posts: 2

PostPosted: Sun Nov 12, 2006 4:52 am    Post subject:
Reply with quote

Can you better explain what you should receive and what you receive now ?

You should also write the Unix key of tabe001 an table002 ... and , if necessary, the tables of every column.

check the join also.
icon_wink.gif
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Sun Nov 12, 2006 5:15 am    Post subject: Re: Order by query is not giving the appropriate results
Reply with quote

adarsh,

Use ORDER BY at last after FETCH. Like this...

Code:
FETCH FIRST ROW ONLY
ORDER BY DATE_3 DESC, TIME_3 DESC
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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