A window frame is the ordered subset of rows that contributes to a window-function calculation for the current row. PARTITION BY groups rows into windows; ORDER BY divides each window into progressively larger frames for running totals. section 3.5
Running play-duration total
For song_id = 2, ordering by user_id makes each frame include the current user's rows and preceding users' rows. The resulting totals are 144, 350, 654, and 654 seconds. Duplicate rows for user_id = 3 share the same frame total. section 3.5
Listing 3.13 Calculating running totals and total duration
SELECT song_id, user_id, play_duration, SUM(play_duration) OVER (PARTITION BY song_id ORDER BY user_id) AS total_play_duration FROM streaming.plays WHERE song_id = 2;
Run the query to calculate a running total within a song partition, ordered by user_id. section 3.5

