Your question is Writing Complex Queries. Start with the requirements and the four tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
How would you write complex queries to answer a business question?
Using the supplied customer, order, order item, and support ticket data, produce a monthly performance view for active customers from January through March 2025. Include completed-order revenue, month-over-month revenue change, regional revenue rank, a three-month rolling revenue total, and support ticket volume.
customer_id, customer_name, region, month, monthly_revenue, prior_month_revenue, revenue_growth_pct, regional_monthly_rank, rolling_3_month_revenue, and support_ticket_count.month, region, regional_monthly_rank, and customer_id.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| region | VARCHAR(30) | Customer sales region |
| is_active | BOOLEAN | Whether the customer is active |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Order identifier |
| customer_id | INT | Ordering customer |
| order_date | DATE | Date the order was placed |
| order_status | VARCHAR(20) | Order lifecycle status |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Order item identifier |
| order_id | INT | Parent order |
| quantity | INT | Quantity purchased |
| unit_price | NUMERIC(10,2) | Price per unit |
| discount | NUMERIC(10,2) | Order-line discount |
| Column | Type | Description |
|---|---|---|
| ticket_idPK | INT | Support ticket identifier |
| customer_id | INT | Customer who opened the ticket |
| opened_at | DATE | Ticket opening date |
| ticket_status | VARCHAR(20) | Ticket status |