I have an app where I am selecting records with first and the last timestamp for that day. There are more than one rows that satisfies the criteria, I want only the latest for that specific day.
SELECT TIMESTAMP, COUNT(DISTINCT employee_id)
FROM attendance
WHERE Date(TIMESTAMP) BETWEEN STR_TO_DATE('01/04/2019', '%d/%m/%Y')
AND STR_TO_DATE('30/04/2019', '%d/%m/%Y')
AND TIME(TIMESTAMP) < '17:00'
AND employee_id=1111
GROUP BY DATE(TIMESTAMP);
The problem is that it doesn't return the last/latest records for those days.