Choosing the Form the Interviewer Expects

Concepts covered: sqlThreeValuedLogic

This section is the reason this question lives in interview loops. NOT IN with a NULL in the subquery returns zero rows. Not 'some' rows. Not 'wrong' rows. Zero. The dashboard goes to zero. The on-call gets paged. The fix is one character: switch NOT IN to NOT EXISTS. The trap exists because of how SQL's three-valued logic interprets NOT IN. Why NOT IN with a NULL returns zero The bug, demonstrated Walk through a customer who has never ordered. Their customer_id is 5. The subquery returns (1, 2, 3, NULL). The NOT IN evaluates: 5 != 1 (TRUE), 5 != 2 (TRUE), 5 != 3 (TRUE), 5 != NULL (UNKNOWN). The conjunction is TRUE AND TRUE AND TRUE AND UNKNOWN, which is UNKNOWN. UNKNOWN is not TRUE, so customer 5 is excluded. Customer 5 has never ordered, but the query excludes them anyway. Every customer

About This Interactive Section

This section is part of the Anti-Join: Intermediate lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.

How DataDriven Lessons Work

DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.