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
 

 

finding latest record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: finding latest record
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    Post subject: Re: finding latest record
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    Post subject: Re: finding latest record
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    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 Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts finding delayed job/s in OPC jzhardy IBM Tools 0 Mon May 29, 2017 9:04 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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