How do I get the latest data on a specific day? [MySQL]

advertisements

How can I get the latest data of a specific day in MySQL?

Let's assume that I have a column of dates recorded on my database

dates      |     time     |    value
---------------------------------------------
2015-08-05 |    11:03:02  |    200
2015-08-05 |    23:04:22  |    2400
2015-08-07 |    8:00:22   |    500
2015-08-08 |    13:00:11  |    400
2015-08-08 |    13:23:11  |    200
2015-08-09 |    17:00:23  |    2200
2015-08-09 |    17:06:00  |    1290
2015-08-09 |    19:22:00  |    900
2015-08-13 |    01:01:22  |    1010

I want to get the latest data or transaction of a specific date, my desired result would be like this

 dates      |     time    |     value
---------------------------------------------
2015-08-05  |   23:04:22  |    2400
2015-08-07  |   8:00:22   |    500
2015-08-08  |   13:23:11  |    200
2015-08-09  |   19:22:00  |    900
2015-08-13  |   01:01:22  |    1010

Only the latest data of a spefic or distinct date is chosen, what is the possible query with this?


You need to do this way to get that for each dates

select t1.dates,t1.time,t1.value from table as t1 inner join
(
select dates,max(time) as time from table group by dates
) as t2 on t1.dates=t2.dates and t1.time=t2.time