Use WHERE IS NULL to filter for active admissions and JOIN to get patient names
how many patients are currently admitted? discharge_date is null for anyone still here. need count and their names + admit dates. capacity meeting at 8.
| Column | Type | Key |
|---|---|---|
| encounter_id | INT | PK |
| patient_id | INT | FK → dim_patients |
| provider_id | INT | FK → dim_providers |
| department_id | INT | FK → dim_departments |
| admit_date | TEXT | |
| discharge_date | TEXT | |
| diagnosis_code | TEXT | |
| diagnosis_description | TEXT | |
| encounter_type | TEXT | |
| discharge_disposition | TEXT |
| Column | Type | Key |
|---|---|---|
| patient_id | INT | PK |
| first_name | TEXT | |
| last_name | TEXT | |
| date_of_birth | TEXT | |
| gender | TEXT | |
| insurance_type | TEXT | |
| zip_code | TEXT | |
| primary_language | TEXT | |
| is_deceased | INT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Two-table join from encounters to patients, with a NULL-filter on the discharge column to find still-admitted patients.
WHERE the discharge column IS NULL, then project the patient name fields and admit date.
NULL discharge here means 'not yet discharged' — valid data, not dirty data. The filter operator is IS NULL, not = NULL.