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
A regional summary counts customers per region. Two customers have no region assigned, and they still need to appear rather than being quietly dropped. Return one row per region, unassigned last.
Result columns · in this order
region | The region, or 'unassigned' when none is set. |
customers | How many customers are in it. |
How to approach it
Group by the raw column and label the missing value in the SELECT.
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
| region | customers |
|---|---|
| North | 2 |
| South | 1 |
| unassigned | 2 |
3 rows — all rows shown.
Constraints
unassigned, not one row each.NULL region.Worked example
Bo Lindqvist and Eve Marsh both have a NULL region. GROUP BY region puts the two of them into one group, and COUNT(*) reports 2.
That is worth pausing on, because NULL = NULL is not true — joining the table to itself on region matches none of those rows. Grouping and comparison treat NULL differently on purpose: GROUP BY and DISTINCT treat all NULLs as the same value, while = treats each as unknown.
What this tests
That GROUP BY collects all NULLs into a single group even though NULL = NULL is never true — an asymmetry that decides whether missing data shows up in a report or disappears from it.
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.