[AccessD] SQL Time

David McAfee davidmcafee at gmail.com
Tue Dec 11 15:24:17 CST 2012


is there a PKID for the table?

SELECT PKID, MAX(SomeDateFiekd) AS MaxDate FROM SomeTable


You'll have to join back to the same table if you want more data from the table:

SELECT B.*
FROM
(SELECT PKID, MAX(SomeDateField) AS MaxDate FROM SomeTable) A
INNER JOIN SomeTable B ON A.PKID = B.PKID AND A.MaxDate = B.SomeDateField


On Tue, Dec 11, 2012 at 12:58 PM, Kaup, Chester
<Chester_Kaup at kindermorgan.com> wrote:
> I have a database with linked SQL server table. I need to extract some records from the table. Some days there is more than one record; ie two records with different times. I need to grab the last record on those days. So far I have not come up with a way. Your ideas appreciated.
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list