D8LooPFocus modeCODE WORKSPACE
Return one row: total_customers, missing_country (customers with a NULL country), and missing_rate as a 2-decimal text value.
Count the NULLs with a CASE inside SUM, divide by COUNT(*) in decimal math, then format with printf('%.2f', ...).
Sample input
| customer_id | country |
|---|---|
| 1 | US |
| 2 | null |
| 3 | GB |
| 4 | IN |
| 5 | US |
| 6 | GB |
Expected output
| total_customers | missing_country | missing_rate |
|---|---|---|
| 6 | 1 | 0.17 |
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.
Run the SQL query to inspect preview rows.