RIGHT JOIN
between the Sessions
table and the CTE on the condition that the duration
of the session falls within the min and max duration of the bin.COUNT
to aggregate the number of sessions for each bin.COALESCE
or IFNULL
to handle cases where there are no sessions in a bin, ensuring they show up with a count of 0.erDiagram Sessions { int session_id PK "Unique session identifier" int duration "Duration of the session in seconds" }