69. Province Average Cost Outliers

Hard Snowflake Advanced & Tricky Problems
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
patients
10 cols
doctors
4 cols
admissions
7 cols
province_names
2 cols

Reference Solution

Expected SQL
SELECT p.first_name, p.last_name, p.province_id, a.admission_cost FROM admissions a JOIN patients p ON a.patient_id = p.patient_id WHERE a.admission_cost > (SELECT AVG(a2.admission_cost) FROM admissions a2 JOIN patients p2 ON a2.patient_id = p2.patient_id WHERE p2.province_id = p.province_id);
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.