Write a SQL query to identify the top three user segments by engagement over the last quarter.
Use the provided Wise. Energy user, segment, and engagement data. Define engagement as the number of engagement events during the previous calendar quarter.
Output
- One row per selected segment with
segment_name, engagement_count, and active_users
- Include only the top three segments, ordered by engagement count descending and segment ID ascending for ties
Output details
- Treat
DATE '2026-09-15' as today's date.
- Count
active_users as distinct users having at least one engagement event during the previous calendar quarter.
- Exclude segments with no engagement events during the previous calendar quarter.
- Order final ties by
segment_name ascending, despite selecting tied ranks by segment ID ascending.