Deduplication & latest-record
Exercise · SQL & Querying

Predict, then run it

Predict the output

fittings(cust, ts) = (7,5),(7,3),(9,2). Last fitting per customer — the correlated way, so no customer drops out:

SELECT cust, ts FROM fittings f WHERE ts = (SELECT MAX(ts) FROM fittings f2 WHERE f2.cust = f.cust) ORDER BY cust;

Predict the exact output.