Branches With Above-Average Water Flow
Problem
A municipal water utility records every metered flow between water meters. Each meter belongs to one branch office, identified by an area code embedded in the meter records.
Write a query that returns the branches whose **average flow per logged transfer is strictly greater than the global average flow per transfer** across the whole network. A meter participates in a transfer whether it is the source or the target of the flow.
Return one column named `region` (the branch city). Order does not matter.
Tables
Example rows — the live problem includes the full dataset.
| branch_id | city | area_code |
|---|---|---|
| 1 | Riverside | RV |
| 2 | Hilltop | HT |
| 3 | Lakeview | LV |
| meter_id | branch_id |
|---|---|
| 10 | 1 |
| 11 | 1 |
| 20 | 2 |
| source_meter | target_meter | litres |
|---|---|---|
| 10 | 30 | 33 |
| 20 | 30 | 4 |
| 10 | 20 | 59 |
Expected output
Your answer should return 2 rows with the columns region.
Starter code (SQL)
SELECT *
FROM branch;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