Select Max Time and Max Date from table where time and date are in separate columns
Posted on 2012-03-16
Thank you for looking at my question,
I have a table, Table X, of transactions orderer by date and time. I want to select the most recent transaction.
The transaction date (TransDate) is the date only eg 15/03/2012
The transaction time (TransTime) shows date and time in the format 01/01/1900 12:43:29
Currently I obtain the most recent transaction by first querying Table X for Max(TransDate)
I use a second query to get the latest time for the most recent date
SELECT Max(TransTime) FROM qryTableX_MaxDate INNER JOIN TableX ON qryTableX_MaxDate.MaxOfTRAN_DATE = TableX.TransDate
GROUP BY qryTableX_MaxDate.MaxOfTransDate
How do I do this in one query?