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
Return one row: total_customers, missing_country (customers with a NULL country), and missing_rate as a 2-decimal text value.
Result columns · in this order
total_customersmissing_countrymissing_rateHow to approach it
Count the NULLs with a CASE inside SUM, divide by COUNT(*) in decimal math, and format with printf.
Sample input
| customer_id | country |
|---|---|
| 1 | US |
| 2 | null |
| 3 | GB |
| 4 | IN |
| 5 | US |
| 6 | GB |
6 rows — all rows shown.
Expected output
| total_customers | missing_country | missing_rate |
|---|---|---|
| 6 | 1 | 0.17 |
1 row — all rows shown.
Constraints
Test missingness with country IS NULL (never = NULL). Force decimal math with 1.0 * ... / COUNT(*), then wrap the rate in printf('%.2f', ...).
Expected skills
Completeness checks, IS NULL counting, and decimal-safe rate formatting.
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.