About the “Drug-Allergy Interaction Warning Join” SQL Problem
Business Scenario
Patient safety software automatically flags orders when a physician prescribes a medication containing an active chemical ingredient matching a recorded patient allergy.
Expected Output & Criteria
Flagged prescriptions where prescribed drug substance matches documented patient allergies.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE patient_allergies (
allergy_id INT PRIMARY KEY,
patient_id INT NOT NULL,
allergen_substance VARCHAR(60) NOT NULL,
severity VARCHAR(30) NOT NULL
);
CREATE TABLE prescriptions (
prescription_id INT PRIMARY KEY,
patient_id INT NOT NULL,
medication_name VARCHAR(80) NOT NULL,
active_ingredient VARCHAR(60) NOT NULL
);Target SQL Clauses & Operators
JOINONORDER BY
Want more Joins practice?
Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.