Hi,
The way to do this is a co-related sub query with a self join.
See example below : ( You can substitute timestamp for date)
DESC ALD1 table
NAME Null? Type
------------------------------- --------- -----
ID NUMBER
ST_DT DATE
ID ST_DT
-- ----------
1 1-Dec-2007
1 5-Dec-2007
1 10-Dec-2007
2 2-Feb-2008
2 31-Jan-2008
The following query will select rows with the latest date
select * from ald1 a
where st_dt = ( select max(st_dt) from ald1 b
where a.id = b.id
)
ID ST_DT
-- -----------
1 10-Dec-2007
2 2-Feb-2008
Hope this helps.
Ashim.
-----Original Message-----
From: Khan Nadeem
[mailto:db2udbdba-ezmlmshield-x86277236.[Email address protected]
Sent: Wednesday, January 16, 2008 12:14 AM
To: LazyDBA Discussion
Subject: timestamp ...............urgent
Hi Gurus
I have a table with a timestamp column
Now I want to find out the latest value of timestamp i.e in the last row
or the latest record
So do we have any provision in DB2 to find the same
I mean I want to update some columns based on latest timestamp value
i.e. in last row of timestamp column
Thanks,
Nadeem Khan
This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is intended only for the
person to whom it is addressed. If you are not the intended recipient,
you are not authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies of this message.
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
DB2 & UDB email list listserv db2-l LazyDBA home page