The query below, obtains the latest record by Reading_Date for Device_Address 0 to 15. This worked fine, until I got a few thousand records, I've got 10,000 records now, and it takes approx 5 minutes to complete.

"SELECT SQL_BIG_RESULT
descriptors.Descriptor,
readings.Device_Address,
readings.Reading_Date as Reading_Date,
readings.Calibration_Date,
CASE WHEN readings.Low_Battery = 0 then 'FALSE' ELSE 'TRUE' END as Low_Battery,
CASE WHEN readings.Calibration_Over_Due = 0 then 'FALSE' ELSE 'TRUE' END as Calibration_Over_Due
FROM readings INNER JOIN descriptors ON readings.device_address = descriptors.device_address
WHERE readings.Reading_Date IN (SELECT MAX(readings.Reading_Date) FROM readings group by readings.Device_Address)
ORDER BY readings.Device_Address";

Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.