|
A few ways to do it: 1) Convert date/time to timestamp 2) Concat date & time into one field (either numerically or as char) 3) multiple steps - see example below With tbl as (select fld1, fld2, logDate, max(logtime) as maxTimeforDate from file group by fld1, fld2, logDate ) Select fld1, fld2, max(logDate) as maxDate, maxTimeforDate
From tbl
Group by fld1, fld2, maxTimeForDate HTH, Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121
-----Original Message----- From: wdsci-l-bounces@xxxxxxxxxxxx [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Smith, Mike Sent: Thursday, August 31, 2006 3:34 PM To: wdsci-l@xxxxxxxxxxxx Subject: [WDSCI-L] SQL getting record with last date/Time L ADMIN_BW HARLESSD 20060830 155855 U ADMIN_BW CHISOMT 20060831 143021 L ADMIN_BW CHISOMT 20060831 143250 I need to do an sql select statement that will retrieve the highest date in a file, but also the highest time for that particular date. Originally I was just getting the latest date with a Select max(logDate). I then tried knowing it wouldn't work Select max(logdate), max(logTime). In the above records I would want 20060831- 143250 How would I accomplish this? Michael Smith iSeries.mySeries. -- This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.