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
 

 

Query on DB2 ....

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

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 8:21 pm    Post subject: Query on DB2 ....
Reply with quote

Hi,
I need a help.
I have several entries in my DB2 table like,
10 STATUS1
10 STATUS2
10 STATUS3
10 STATUS4
I need to read the current entry from the DB2 table. According to my example it is STATUS4, if in this case I need to fetch the previous of that from the table ie) STATUS3 needs to be fetched.
Could you please help me on how this could be done???
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 10, 2013 8:49 pm    Post subject:
Reply with quote

You recognize that "the previous" is undefined (as well as bad English) unless the SELECT includes an ORDER BY clause, yes?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Apr 10, 2013 8:51 pm    Post subject:
Reply with quote

You need to explain the significance of statuses indirectly atleast so someone can assist
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 10, 2013 9:51 pm    Post subject:
Reply with quote

Hello,

How does one know that STATUS4 is "current"?

Do the rows contain a date/time stamp?

What if STATUS3 was deleted and then re-inserted - is this now "current"?
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 9:54 pm    Post subject:
Reply with quote

Even though I use the SELECT with ORDER BY i could arrange them in an ASC or DSC, but how could I get the last previous exactly from my DB2 table :-(

Also as you asked the significance of status field, using this status field there are going to be some online process and DB2 table updation.

Please let me know if you need any more information...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Apr 10, 2013 9:56 pm    Post subject: Reply to: Query on DB2 ....
Reply with quote

Quote:
Please let me know if you need any more information...


describe the logic to determine the current entry
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 10, 2013 10:10 pm    Post subject:
Reply with quote

Hello,

Quote:
but how could I get the last previous exactly from my DB2 table
I suspect, You will need to include "something" in the design of the table to support "most current".
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
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts SQL Query optimization. arunsoods DB2 12 Sun Sep 04, 2016 6:27 am
No new posts Query on BLSR Nileshkul JCL & VSAM 2 Sat Aug 13, 2016 5:18 am


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