Write a SQL query using window functions to identify the most recent clinical reading for each dialysis patient at Fresenius Medical Care North America.
Use the provided patient and clinical reading data. Return only dialysis patients with at least one reading, selecting the latest timestamp and using the reading ID to break timestamp ties.
patient_id, patient_name, reading_id, reading_type, reading_value, unit, and reading_timestamp.patient_id ascending.| Column | Type | Description |
|---|---|---|
| patient_idPK | INT | Unique dialysis patient identifier |
| patient_name | VARCHAR(100) | Patient name |
| is_dialysis_patient | BOOLEAN | Whether the patient is currently identified as a dialysis patient |
| Column | Type | Description |
|---|---|---|
| reading_idPK | INT | Unique clinical reading identifier |
| patient_id | INT | Patient associated with the reading |
| reading_type | VARCHAR(50) | Type of clinical measurement |
| reading_value | DECIMAL(8,2) | Recorded clinical measurement value |
| unit | VARCHAR(20) | Unit of measurement |
| reading_timestamp | TIMESTAMP | Timestamp when the reading was recorded |