Hi can anybody tell me how to get the latest data logged in database while sending the query. Like i have MS Access database in which i have logged data along with time-stamping, so when i send a query i should get only the latest information stored in it or get the latest data from it based on the last recorded time.
My access database has the following data:
DEVICENAME WINDOW DATE TIME
Device1 WIN1 6/10/2013 11:16 AM
Device1 WIN2 6/10/2013 11:16 AM
Device2 WIN7 6/10/2013 11:16 AM
Device2 WIN7 6/10/2013 11:16 AM
Device1 WIN1 6/10/2013 11:20 AM
Device1 WIN2 6/10/2013 11:20 AM
Device1 WIN3 6/10/2013 11:20 AM
As you can see device1 is logged twice @ different intervals, but from these logged data i need only the latest logged data i.e., device1 logged @ 11:20AM. How do i initiate a query for this case.
Loading

Vijay YadavRank #1,637 · 943 reputationPosted Jun 10, 2013, 2:33 AM EDT
Can you please tell us, is it necessary to have to different column for date and time?
if not then it can be resolved easliy by the below query
select * from tablename where datecolumn = (select max(datecolumn) from tablename)
or else you need to have a 2 conditions in where clause one for date and another for time.
Jagadisha N4 reputationPosted Jun 10, 2013, 3:50 AM EDT
Thanks for your reply, but i also want to return device name & its latest timestamp data. So with the query you have posted i may retrieve only the latest or max of datetime, for retrieving device name if i include a query like shown below:
"SELECT window, Time from ErrorLog where DEVICENAME='" + btn[add].Text + " and Time = (SELECT MAX(Time)) from ErrorLog"
I get an error like this:
Cannot have Memo, OLE, or Hyperlink Object fields in aggregate argument (time).
How to resolve this?
Thanks in advance,
Jagadisha.N