Problems / Event Duration / Editorial
MIN(CASE WHEN event_type = 'start' THEN event_date END)
DATEDIFF('day', start_date, end_date)
session_id
You can also self-join the table—filter for start events and end events separately, then join on session_id. Conditional aggregation avoids the join overhead.
Conditional aggregation with CASE WHEN inside aggregate functions is a powerful technique for pivoting event-based data into a row-per-entity format.
CASE WHEN
Solve Event Duration yourself →