COALESCE and NULLIF
Handling Nulls: COALESCE
COALESCEWhy it is essential
Standard SQL Examples
SELECT
first_name || ' ' || COALESCE(middle_name, '') || ' ' || last_name AS full_name
FROM users;-- If 'tax' is NULL, it is treated as 0
SELECT
price + COALESCE(tax, 0) AS total_cost
FROM sales;Turning Values to Null: NULLIF
NULLIFThe "Divide by Zero" Protection
Combining CAST and COALESCE
CAST and COALESCESummary Reference Table
Last updated