Windows I — ranking & offsets
Exercise · SQL & Querying

Predict, then run it

Predict the output

sales(branch, drink, units) = (north,kale,30),(north,beet,10),(south,mango,22),(south,lime,8). Best-selling drink per branch — the portable-ish QUALIFY spelling:

SELECT branch, drink FROM sales QUALIFY ROW_NUMBER() OVER (PARTITION BY branch ORDER BY units DESC) = 1 ORDER BY branch;

Predict the exact output.