Practice Free
← Syllabus|
Medium

15. Hospital Triage: Elevated Systolic Blood Pressure

MediumFundamentalsPostgreSQL 16PRO
Table: triage_vitals
+--------------+-----------+
| Column Name  | Type      |
+--------------+-----------+
| patient_id   | int       |
| systolic_bp  | int       |
| diastolic_bp | int       |
| recorded_at  | timestamp |
+--------------+-----------+

patient_id is the unique key for this table. Each row contains record details for this enterprise dataset.

Emergency triage clinical systems continuously evaluate vitals recorded at triage check-in to classify hypertension severity for attending nursing staff.

Write a query to retrieve all patient vital readings from `triage_vitals` where `systolic_bp >= 140`. Include a computed column named `hypertension_stage`: - If `systolic_bp >= 180`, classify as `'CRISIS'` - Otherwise, classify as `'STAGE_2'` Return: 1. `patient_id` 2. `systolic_bp` 3. `diastolic_bp` 4. `hypertension_stage` Order results by `systolic_bp` descending, then by `patient_id` ascending.

Return the result table ordered as specified. The result format is in the following example.

Example 1:
Input:
Preparing sample rows...
Output:
Calculating benchmark target...
Explanation:

Patient triage records with elevated systolic readings classified by crisis urgency.

Constraints:
  • Query must utilize clause(s): WHERECASEORDER BY
  • Result order matters (tie-breakers and sort order must be strictly preserved).
  • Engine: PostgreSQL 16 standard syntax (in-browser WASM).
query.sql|PostgreSQL 16 WASM
Loading SQL editor...
You must run your code first

Write your SQL query in the editor and click Run or Submit to test against in-browser PostgreSQL 16 WASM.

About the “Hospital Triage: Elevated Systolic Blood Pressure” SQL Problem

Business Scenario

Emergency triage clinical systems continuously evaluate vitals recorded at triage check-in to classify hypertension severity for attending nursing staff.

Expected Output & Criteria

Patient triage records with elevated systolic readings classified by crisis urgency.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM
CREATE TABLE triage_vitals (
        patient_id INT PRIMARY KEY,
        systolic_bp INT NOT NULL,
        diastolic_bp INT NOT NULL,
        recorded_at TIMESTAMP NOT NULL
      );

Target SQL Clauses & Operators

WHERECASEORDER BY

Want more Fundamentals practice?

Explore the full syllabus of 16 exercises and syntax guides.

View Fundamentals Track