I have table:
id date day
2 21-07 1
2 10-07 3
2 11-07 2
I need to get date
which has highest day
, in current example it should be 10-07. Next query works fine, but is there way to make it more optimised?
SELECT date
FROM (SELECT date, MAX(day)
FROM some_table
WHERE id = 2
GROUP BY date
LIMIT 1) x
I would not suggest a where
clause. Just use:
select date
from some_table
where id = 2
order by day desc
limit 1;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments