item Max SQL help

  • Thread starter Thread starter John
  • Start date Start date
J

John

hi id like to get this query -

SELECT HistoryLog.ItemDATE, TimeValue([ItemTIME])
AS ItemTIMEValue, HistoryLog.GENSETNAME, HistoryLog.kWhrs,
HistoryLog.Runhrs, HistoryLog.Pwr, HistoryLog.numst, HistoryLog.REASON
FROM HistoryLog
WHERE (((HistoryLog.REASON)="Time stamp"))
ORDER BY HistoryLog.ItemDATE, TimeValue([ItemTIME]);

to only return the max of ItemTIME. Ive been trying all sorts but cant get
it to work
Many Thanks
 
Are you saying that you want the values of ItemDATE, GENSETNAME, kWhrs,
Runhrs, Pwr, numst and REASON associated with the max of ItemTIME?

SELECT ItemDATE, TimeValue([ItemTIME]) AS ItemTIMEValue,
GENSETNAME, kWhrs, Runhrs, Pwr, numst, REASON
FROM HistoryLog
WHERE REASON="Time stamp"
AND ItemTIME IN (SELECT Max(ItemTime) FROM HistoryLog)
ORDER BY HistoryLog.ItemDATE, TimeValue([ItemTIME]);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top