Write a SQL query to measure weekly application-to-funding conversion by channel, including counts at each stage and conversion rates. Use the applications and application_events tables. Attribute each application to the week in which it was submitted, and count an application once per stage even if duplicate events exist.
week_start, channel, application_count, approved_count, funded_count, approval_rate_pct, funding_rate_pct, and approval_to_funding_rate_pct.week_start, then channel, with null channels last.| Column | Type | Description |
|---|---|---|
| application_idPK | INT | Unique application identifier |
| channel | VARCHAR(30) | Acquisition channel associated with the application |
| applied_at | TIMESTAMP | Timestamp when the application was submitted |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique application event identifier |
| application_id | INT | Application associated with the event |
| event_type | VARCHAR(20) | Lifecycle event type, such as approved or funded |
| occurred_at | TIMESTAMP | Timestamp when the event occurred |