Write a SQL query to calculate the month-over-month conversion rate of leads moving from marketing qualified lead (MQL) to sales qualified lead (SQL) for Pagerduty.
Use the provided lead and stage-event data. Count each lead at most once in its MQL month, and only count an SQL event occurring at or after that lead's MQL timestamp. Leads with a NULL MQL timestamp are ignored.
month, mql_count, sql_converted_count, conversion_rate_pct, and mom_change_pct_points.mom_change_pct_points is the change from the previous month's conversion rate and is NULL for the first month.| Column | Type | Description |
|---|---|---|
| lead_idPK | INT | Unique identifier for the lead |
| mql_at | TIMESTAMP | Timestamp when the lead became marketing qualified |
| lead_source | VARCHAR(50) | Marketing source associated with the lead |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique identifier for the stage event |
| lead_id | INT | Lead associated with the stage event |
| stage | VARCHAR(30) | Lifecycle stage recorded by the event |
| event_at | TIMESTAMP | Timestamp when the stage event occurred |