CODE WORKSPACE

Customer null completeness

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

customersSix customers; only customer 2 has a missing country.
customer_idcountry
1US
2null
3GB
4IN
5US
6GB

Expected output

Expected outputTotal customers, the count missing a country, and the decimal-safe missing rate as text.
total_customersmissing_countrymissing_rate
610.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.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.