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

finding latest record


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

New User


Joined: 04 Mar 2005
Posts: 8
Location: bangalore

PostPosted: Wed Jun 08, 2005 5:16 pm
Reply with quote

Hi,
i need solution to the following problem.
i have a table with the following data-
code status record_insert_date
----- -------- --------------------
1000 w 02-04-2004
2000 e 01-03-2005
1000 w 03-04-2003
1000 w 04-06-2005
1001 e 01-02-2002
----
----
given the code and status, how to find out the most recently inserted record? e.g. if code = 1000 and status=w the record fetched must be the one with record_insert_date=04-06-2005.

Thanks and Regards,
Priyabrata
Back to top
View user's profile Send private message
poolarajesh

New User


Joined: 22 Jan 2004
Posts: 4

PostPosted: Wed Jun 08, 2005 5:51 pm
Reply with quote

Hi,

Use max function to get the latest date as shown below.

select (req fields)
from table name
where code = 1000
and status = 'w'
and record_insert_date = (select max (record_insert_date )
from table name
where code = 1000
and status = 'w')


Correct me if i am wrong.


Rajesh
Back to top
View user's profile Send private message
nrsmca

New User


Joined: 25 May 2005
Posts: 14

PostPosted: Fri Jun 10, 2005 10:51 am
Reply with quote

select (a.cols,?)
from tablename a
and a.record_insert_date = (select max (b.record_insert_date )
from tablename b
where b.code = 1000
and b.status = 'w')
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 Finding and researching jobs All Other Mainframe Topics 0
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts VB to FB - Finding LRECL SYNCSORT 4
Search our Forums:

Back to Top