From below table I want to extract the column values (C_Number) with the latest TimeStamp buy comparing with current system timestamp from db2 table? Please help.
Example: In Table "Computer" there are 3 columns ie
C_Number | C_Data | TimeStamp ------------------------------------------------------------------------------ 12-DFHK | Yes | 2013-08-14 07:33:05.29 13-DFCC | Yes | 2013-08-18 07:45:05.29
Form the above table how can i extract the Column "C_Number" values with latest Timestamp(in this above table latest timestamp is "2013-08-18 07:45:05.29" ) by comparing with current system time.
SELECT C_Number FROM Computer
WHERE TimeStamp = (SELECT MAX(TimeStamp) FROM Computer);
one more efficient way to achive your purpose is the following:
SELECT C_Number
FROM Computer
ORDER BY TimeStamp DESC
FETCH FIRST ROW ONLY ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.