Exercise · SQL & Querying
Predict, then run it
Predict the output
horses(horse, workshop, paint, acquired, inspected) has one horse recorded twice: A (teal, acquired 1990, inspected 2020), B (navy, 1995, 2023). Build the golden record — newest paint, earliest acquisition:
SELECT h.horse, (SELECT paint FROM horses h2 WHERE h2.horse = h.horse ORDER BY inspected DESC LIMIT 1) AS paint, MIN(acquired) AS acquired FROM horses h GROUP BY h.horse;
Predict the exact output.