service_contacts has one row per support call (patient_id, call_date, call_id). Count calls per patient and calendar month ('YYYY-MM'). For every patient-month whose immediately preceding calendar month also has at least one call for that patient, report the month-over-month change: pct_change = 100 * (calls this month - calls previous month) / calls previous month. Months whose previous calendar month had no calls are not reported. Output columns: patient_id, month, pct_change (rounded to 2 decimals). Order by patient_id, then month.
| Column | Type |
|---|---|
| patient_id | INTEGER |
| call_date | DATE |
| call_id | INTEGER |
| patient_id | call_date | call_id |
|---|---|---|
| 101 | 2026-01-02 | 1 |
| 101 | 2026-01-10 | 2 |
| 101 | 2026-02-01 | 3 |
| 101 | 2026-02-05 | 4 |
| 102 | 2026-01-03 | 5 |
| 102 | 2026-02-02 | 6 |
| patient_id | month | pct_change |
|---|---|---|
| 101 | 2026-02 | 0 |
| 102 | 2026-02 | 0 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Three-Ingredient Meal Bundles · Regional Support Leaders ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.