I got a query where I´m supposed to show the latest record of my users, I can filter by user or not. Here is an example of the data
id fecha no_emp
1326 2016-06-20 16:31:48 69976
1327 2016-06-20 16:31:38 69976
1328 2016-06-20 16:31:48 69976
1329 2016-06-21 17:22:37 69976
1330 2016-06-21 17:22:37 69976
1331 2016-06-27 13:06:22 69976
I´m supposed to get id 1331, and date 2016-06-27 13:06:22 But keep getting id 1326 and date 2016-06-20 16:31:48 if my query is:
SELECT id, fecha, no_emp
FROM of_direcciones
WHERE no_emp = '69976'
GROUP BY no_emp
order by ID DESC;
and I get id 13226 and date 2016-06-27 13:06:22 if my query is:
SELECT id, MAX(fecha), no_emp
FROM of_direcciones
WHERE no_emp= '69976'
GROUP BY no_emp;
What´s wrong in my query? Thanks in advance