Averages and totals are not the only thing a window can produce. Give it an ORDER BY and it can number the rows: ROW_NUMBER() gives each row its position, strongest Codémon first:
↗️
Loading editor...
↶
↷
Aquachu is 1, Pyrochu 2, down to Plantachu at 8. The ORDER BYinside the window decides the numbering; the query's own ORDER BY decides the display — two different things, and you will often write both.
Add PARTITION BY and the numbering restarts in each group:
↗️
Loading editor...
↶
↷
Position 1 in each team is the strongest Codémon of that trainer — keep that in mind, it is the key to "the best of each group" later in this lesson.
ROW_NUMBER needs an order
Without ORDER BY inside OVER, ROW_NUMBER still runs, but the numbers follow whatever order the database happened to use — unpredictable. Always give it an ORDER BY.