Write a query to identify top-performing user segments based on multi-step conversion funnels.
Calculate performance for the funnel viewed_offer → started_application → completed_application. A user counts as started only when the start occurs after the view, and counts as completed only when completion occurs after the start. Include every segment, including segments with no qualifying starters.
segment, started_users, completed_users, conversion_rate, and performance_rank.conversion_rate is the completed-user percentage among qualifying starters, with zero for segments without starters.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| segment | VARCHAR(50) | User segment label |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier |
| user_id | INT | User associated with the event |
| event_name | VARCHAR(40) | Funnel event type |
| event_at | TIMESTAMP | Timestamp when the event occurred |