Write a SQL query to combine operations, customer, and revenue data to identify the top accounts by monthly usage, support tickets, and renewal risk.
Use January and February 2025 data. Include each account's monthly usage, support ticket count, revenue, and renewal risk score. Treat a month-over-month usage decline as an additional renewal risk signal.
month_start, account_id, account_name, monthly_usage, support_tickets, renewal_risk_score, monthly_revenue, and account_rank.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique customer account identifier |
| account_name | VARCHAR(100) | Customer account name |
| segment | VARCHAR(30) | Customer segment |
| account_status | VARCHAR(20) | Account lifecycle status |
| Column | Type | Description |
|---|---|---|
| usage_event_idPK | INT | Unique usage event identifier |
| account_id | INT | Customer account associated with the usage |
| usage_date | DATE | Date of usage |
| usage_units | INT | Units consumed during the event |
| Column | Type | Description |
|---|---|---|
| ticket_idPK | INT | Unique support ticket identifier |
| account_id | INT | Customer account that opened the ticket |
| opened_at | DATE | Date the ticket was opened |
| ticket_priority | VARCHAR(20) | Support ticket priority |
| ticket_status | VARCHAR(20) | Support ticket status |
| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Customer account identifier |
| monthly_revenue | DECIMAL(12,2) | Current monthly recurring revenue |
| renewal_date | DATE | Contract renewal date |
| renewal_risk_score | INT | Base renewal risk score from 0 to 100 |