service_contacts has one row per support call (patient_id, call_time). For each patient, compute the time between their first and their most recent call in whole hours, rounded down (a patient with a single call gets 0). Output columns: patient_id, elapsed_hours. Order by patient_id ascending.
| Column | Type |
|---|---|
| patient_id | INTEGER |
| call_time | TIMESTAMP |
| patient_id | call_time |
|---|---|
| 101 | 2026-01-01 09:00:00 |
| 101 | 2026-01-03 10:00:00 |
| 102 | 2026-02-01 12:00:00 |
| 102 | 2026-02-05 12:00:00 |
| patient_id | elapsed_hours |
|---|---|
| 101 | 49 |
| 102 | 96 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
{{ 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.