Your question is SQL Top Row Retrieval. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write SQL to get the top row of a column.
Assume the top row is the complete row with the highest non-NULL visit_count. If multiple rows share the highest value, return the row with the smallest encounter_id.
clinical_encounters.visit_count is NULL.visit_count, then lowest encounter_id.| Column | Type | Description |
|---|---|---|
| encounter_idPK | INT | Unique identifier for the encounter |
| patient_id | INT | Identifier of the patient |
| provider_name | VARCHAR(100) | Name of the assigned provider |
| encounter_type | VARCHAR(50) | Type of clinical encounter |
| visit_count | INT | Number of visits represented by the encounter record |