26. Same-Allergy Geographic Co-location

Medium Uber Joins (All Types)
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 p1.first_name as p1_first, p2.first_name as p2_first, p1.city, p1.allergies FROM patients p1 JOIN patients p2 ON p1.city = p2.city AND p1.allergies = p2.allergies AND p1.patient_id < p2.patient_id WHERE p1.allergies IS NOT NULL;
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.