The patient name on the wristband
The patient name on the wristband
You are a reports developer at a clinic. The patient wristband printer needs a single field with the full name: last name, first name and — when present — the middle name, separated by single spaces. Some patients have no middle name (NULL), and the band must contain no double or trailing spaces: the admissions scanner compares the name character by character.
Return columns:
- patient_id — patient id (integer);
- full_name — a string of the form 'Lastname Firstname Middlename' with a single space as separator; when the middle name is missing it simply does not participate (no stray trailing spaces).
Sorting: by full_name ascending, identical names ordered by patient_id ascending. Return all patients.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.
| patient_id | full_name |
|---|---|
| 4 | Bauer Chris |
| 10 | Costa Bruno Miguel |
| 7 | Hansen Freja |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in