3
I need to search the database for the last 4 most recent records, the column being exr_exa_id
is in agreement with the informed Ids, and exr_exa_id
may not be duplicated.
I tried to group in some ways, but I was unsuccessful, because either it does not display the most recent records, or it displays equal records in the column exr_exa_id
(see image).
Can you help me?
SELECT *
FROM exa_exameresultado
WHERE
exr_exa_id IN (18,19,20,71) AND
exr_pac_id = 2128
ORDER BY
exr_data DESC,
exr_exa_id ASC
LIMIT 4
Put it on http://sqlfiddle.com/, so you can help us help you :)
– Dherik
follow link http://sqlfiddle.com/#! 9/58d88/1/0
– Thiago Alessandro
When placing the group by, it changes the date... Ex: the + recent date for the exr_exa_id field of value 18 is 2015-04-09. When placing a group by in exr_exa_id, it changes the date of this record to 2014-10-07
– Thiago Alessandro