I have a table as follows
ID apiDate totalCases
1 2020-04-18 12:00:00 10
2 2020-04-18 12:00:00 15
3 2020-04-19 12:00:00 20
4 2020-04-19 12:00:00 25
5 2020-04-19 12:00:00 30
6 2020-04-20 12:00:00 35
7 2020-04-20 12:00:00 40
8 2020-04-20 12:00:00 45
I want to return the latest record for each day as follows
ID apiDate totalCases
2 2020-04-18 12:00:00 15
5 2020-04-19 12:00:00 30
8 2020-04-20 12:00:00 45
I have added another column named 'dateonly' and achieved my requirement
SELECT
*
FROM
myTable H
WHERE
`apiDate` =
(
SELECT
max(`apiDate`)
FROM
myTable
WHERE
`dateonly` = H.dateonly
)
I'm looking for a proper solution without adding column 'dateonly'