mysql last date

Solutions on MaxInterview for mysql last date by the best coders in the world

showing results for - "mysql last date"
06 Jan 2017
1-- Max date for each model:
2SELECT model, max(date) FROM models GROUP BY model;
3-- All models matching the max date of the entire table:
4SELECT model, date FROM models WHERE date IN (SELECT max(date) FROM models);
5-- Same with model details:
6SELECT d.model,, d.color, d.etc FROM models d
7WHERE IN (SELECT max( FROM models d2 WHERE d2.model=d.model);
8-- Faster with MySQL 8.0+
9SELECT model, date, color, etc FROM (SELECT model, date, color, etc, 
10  max(date) OVER (PARTITION BY model) max_date FROM models) predoc 
11WHERE date=max_date;