← All Exercises

NULL Handling with COALESCE

basicsql~10min

Background

NULL handling is critical for data integrity in SQL since NULL propagates through calculations.

Problem

Handle NULL values in calculations using COALESCE for defaults and NULLIF for division safety.

Input

Data with NULL values

Output

Clean results with defaults

Sample tests

Sample 1

Input: NULL in price column
Expected: 0 or default

Your solution

Learning objective

Learn NULL semantics and safe value handling