Listening Hours by Month

Listening Hours by Month

You are a product analyst at Wavelane, a music streaming service. The growth team tracks engagement and wants a monthly view: how many plays users started and how many total hours of music they listened to. In play_events each row is a single playback with its exact start time and duration in seconds. Group the plays by calendar month and compute totals. A month must be represented by its first day. A play belongs to the month of its start moment, even if it lasted into the next month. Return columns: - month_start — first day of the month (date, YYYY-MM-DD); - plays_cnt — number of plays in the month (integer); - hours_listened — total listening hours, rounded to 1 decimal. Sort by month_start ascending. Zero-length plays count towards plays_cnt but add 0 hours. Months without events must not appear.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

month_startplays_cnthours_listened
2026-01-0130.7
2026-02-0140.9
2026-03-0141.1
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid