NULL handling

SQL NULL Handling Interview Questions

NULL handling is what you do about values that are missing. Real tables are full of gaps, and whether you ignore them, treat them as zero, or drop the row changes the number you report.

What NULL handling questions ask you to do

Across the questions here, these are the shapes that come up:

  • Average a column where some rows have no value
  • Explain why two counts of the same table disagree
  • Join on a column that is empty on one side
  • Treat a missing value as zero, and justify it
  • Find the rows where a value is missing rather than empty

Common mistakes with NULL handling

NULL is not a value, it is the absence of one, so it is never equal to anything — not even to another NULL. That is why joining on a column that can be empty quietly loses rows, and why a total and a count of the same table can disagree: adding up a column skips the gaps, counting rows does not.

Questions to practice

Roles this comes up in

Companies these come from

Other topics