AnalystPath

Standout Clinics

SQLMediumMid level~15 min

Problem

A health network records monthly metrics for each clinic.

Table: metric
+-------------+--------------+
| Column Name | Type |
+-------------+--------------+
| clinic_id | int |
| metric_name | varchar(255) |
| tally | int |
+-------------+--------------+
(clinic_id, metric_name) is the primary key. Each row holds one clinic's tally for one metric (such as 'visits', 'referrals', or 'screenings').

Write a solution to find all standout clinics. A clinic is a standout when it beats the network-wide average for more than one metric, where beating means its tally for that metric is strictly greater than the average tally of that same metric across all clinics. Return a single column clinic_id in any order.

Tables

Example rows — the live problem includes the full dataset.

metric
clinic_idmetric_nametally
1referrals7
3referrals3
1visits11

Expected output

Your answer should return 1 row with the columns clinic_id.

Starter code (SQL)

SELECT *
FROM metric;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions