Numbering rows
The simplest application for window functions is numbering rows. Numbering rows allows you to easily fetch the n
th row. For example, it would be very difficult to get the 35th row in any given table if you didn't have a column with each row's number.
This exercise is part of the course
PostgreSQL Summary Stats and Window Functions
Exercise instructions
- Number each row in the dataset.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
*,
-- Assign numbers to each row
___ ___ AS Row_N
FROM Summer_Medals
ORDER BY Row_N ASC;