I've the database table logs because the following:

alt text

I must extract the final entry of device, pollDate, status. For eg.

deviceId, pollDate, status

1, 2010-95-06 10:53:28, 1

3, 2010-95-06 10:26:28, 1


I attempted to operate the next query however the distinct only chooses the very first records, not the most recent

SELECT DISTINCT deviceId, pollDate, status
FROM logs
GROUP By deviceId
ORDER BY pollDate DESC

alt text

So, would you help me to extract the most recent records in the table? Thanks.

If (deviceID, poll_date) is exclusive, that you can do the next:

SELECT  *
FROM    (
        SELECT  deviceid, MAX(poll_date) AS md
        FROM    logs
        GROUP BY
                deviceid
        ) q
JOIN    logs l
ON      l.deviceid = q.deviceid
        AND l.poll_date = q.md