0
← Exercises/
Fundamentals•11 of 12
FundamentalsBeginnerPRO

Critical Inpatient ICU Bed Priority Logic

Scenario

The chief medical officer needs to audit patient transfer eligibility for Intensive Care Units (ICU). Patients require immediate ICU transfer if they have oxygen saturation below 90% OR (systolic blood pressure above 180 AND heart rate above 120).

Task
Filter the `inpatient_vitals` table for patients who meet either of these critical clinical conditions: 1. `oxygen_pct` is strictly less than **90** 2. **OR** (`systolic_bp` is strictly greater than **180** **AND** `heart_rate` is strictly greater than **120**) Return: 1. `patient_id` 2. `ward_unit` 3. `oxygen_pct` 4. `systolic_bp` 5. `heart_rate` Order results by `oxygen_pct` ascending, breaking ties by `patient_id` ascending.
Expected Output Format

Inpatients in clinical distress requiring ICU escalation, sorted by lowest oxygen saturation.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Critical Inpatient ICU Bed Priority Logic” SQL Problem

Business Scenario

The chief medical officer needs to audit patient transfer eligibility for Intensive Care Units (ICU). Patients require immediate ICU transfer if they have oxygen saturation below 90% OR (systolic blood pressure above 180 AND heart rate above 120).

Expected Output & Criteria

Inpatients in clinical distress requiring ICU escalation, sorted by lowest oxygen saturation.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE inpatient_vitals (
        patient_id INT PRIMARY KEY,
        ward_unit VARCHAR(50) NOT NULL,
        oxygen_pct INT NOT NULL,
        systolic_bp INT NOT NULL,
        heart_rate INT NOT NULL,
        requires_ventilator BOOLEAN NOT NULL
      );

Target SQL Clauses & Operators

WHEREORAND

Want more Fundamentals practice?

Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.

View Fundamentals Track→