Exercise · SQL & Querying
Predict, then run it
Predict the output
members(cust, city) = (7,Rome),(7,Oslo) — one member, two address rows. One row per member, newest city wins:
SELECT cust, city FROM (SELECT cust, city, ROW_NUMBER() OVER (PARTITION BY cust ORDER BY city DESC) AS rn FROM members) WHERE rn = 1;
Predict the exact output.