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

Order by query is not giving the appropriate results


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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: 1448
Location: Chicago, IL

PostPosted: Sun Nov 12, 2006 5:15 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Rotate partition-logical & physic... DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top