Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
The UI shows each customer as a single line: their name, then their region in brackets. Two customers have no region yet.
Return one label per customer, ordered by customer_id.
Result columns · in this order
customer_id | The customer. |
label | Their display label. |
How to approach it
Replace the missing value before you build the string, not after.
Sample input
| customer_id | full_name | region | signed_up_on |
|---|---|---|---|
| c1 | Ada Okafor | North | 2025-11-02 |
| c2 | Bo Lindqvist | null | 2025-12-14 |
| c3 | Chen Wei | South | 2026-01-03 |
| c4 | Dara O'Neill | North | 2026-01-20 |
| c5 | Eve Marsh | null | 2026-02-01 |
5 rows — all rows shown.
Expected output
| customer_id | label |
|---|---|
| c1 | Ada Okafor (North) |
| c2 | Bo Lindqvist (unknown) |
| c3 | Chen Wei (South) |
| c4 | Dara O'Neill (North) |
| c5 | Eve Marsh (unknown) |
5 rows — all rows shown.
Constraints
Ada Okafor (North).Bo Lindqvist (unknown) — never an empty cell.Worked example
full_name || ' (' || region || ')' looks right and produces NULL for c2 and c5.
Concatenation propagates NULL: joining anything to an unknown value gives an unknown result, so one missing region wipes out the entire label rather than leaving a gap in the middle of it.
What this tests
That NULL propagates through expressions rather than behaving like an empty string, and that a default has to be supplied before the value is used.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.