Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Finding IMS resource blocker after se... Hooman24 IMS DB/DC 1 Wed Aug 16, 2017 9:17 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us