Return NULL when two expressions are equal.
Section: Conditional, NULL, and Conversion Functions
Convert a value to NULL conditionally
sql
sql
SELECT revenue / NULLIF(order_count, 0) AS revenue_per_order
FROM daily_metrics;Explanation
NULLIF is often used to avoid divide-by-zero errors.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Conditional, NULL, and Conversion Functions