About the “Inpatient Primary Attending Physician Roster” SQL Problem
Business Scenario
During daily morning hospital rounds, clinical operations generates a roster cross-referencing active inpatients with their assigned attending physician and clinical specialty.
Expected Output & Criteria
Roster of admitted inpatients with attending physician details, sorted by ward room.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE physicians (
doctor_id INT PRIMARY KEY,
doctor_name VARCHAR(80) NOT NULL,
specialty VARCHAR(50) NOT NULL
);
CREATE TABLE hospital_patients (
patient_mrn VARCHAR(20) PRIMARY KEY,
patient_name VARCHAR(100) NOT NULL,
ward_room VARCHAR(20) NOT NULL,
status VARCHAR(20) NOT NULL,
attending_doctor_id INT REFERENCES physicians(doctor_id)
);Target SQL Clauses & Operators
JOINONORDER BY
Want more Joins practice?
Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.