I have a group of currency quotations that change every hour or so. For the sql results in this particular example, I only need the last available record of each day of the last 30 days in yyyy-mm-dd format.
This is my current query:
SELECT value, DATE(date_quotation) as date_q
FROM quotation
GROUP BY DATE(date_quotation)
ORDER BY date_q DESC LIMIT 30
This is used for a histogram chart, where the x axis shows separated days. The quotations table has these columns:
- id_quotation (INT)
- date_quotation (DATETIME)
- value (DECIMAL)
The problem is that it doesn't necessarily bring the last record of the day. It is grouping the records by day, but it should display the one with the highest hour/minute/second. Any ideas? Thanks!