About the “Hospital Ward Inpatient Length of Stay & Bed Occupancy” SQL Problem
Business Scenario
Hospital bed administration needs to optimize ward resource allocation. Operations wants a breakdown of inpatient stays grouped by medical department to identify wards with high patient turnover vs extended average length of stay (ALOS).
Expected Output & Criteria
Summary of department_name, total_admissions, avg_stay_days, and max_stay_days for wards with >= 2 admissions.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE ward_admissions (
admission_id INT PRIMARY KEY,
patient_name VARCHAR(100) NOT NULL,
department_name VARCHAR(50) NOT NULL,
stay_duration_days INT NOT NULL,
discharge_disposition VARCHAR(30) NOT NULL
);Target SQL Clauses & Operators
Want more Aggregations practice?
Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.