DA0-002 practice question 7 of 25

[Data Analysis]A data analyst creates a report, and some of the fields are empty. Which of the following conditions should the analyst add to a query…

Full set: 111 questions

[Data Analysis]

A data analyst creates a report, and some of the fields are empty. Which of the following conditions should the analyst add to a query to provide a list of all the records with empty fields?

Answer options
A: WHERE [ColumnName] = NULL
B: WHERE [ColumnName] IS NULL Correct answer
C: WHERE [ColumnName] IS NOT NULL
D: WHERE [ColumnName] = 'NULL'
Correct Answer:
B. WHERE [ColumnName] IS NULL
Explanation

In standard SQL, NULL is a special marker indicating that a data value does not exist. It is not equivalent to zero or an empty string. Standard comparison operators like = cannot be used to test for NULL because the result of any arithmetic comparison with NULL is also NULL (or unknown), which evaluates to false in a WHERE clause. The correct, standard-compliant operator to specifically test for the absence of a value is IS NULL. This syntax correctly identifies and filters for all records where the specified column is empty.

Why Incorrect

A. WHERE [ColumnName] = NULL is incorrect because the = operator cannot be used to test for NULL values; this expression will not return any rows.
C. WHERE [ColumnName] IS NOT NULL is the opposite of the required logic; it returns records where the field has a value, not where it is empty.
D. WHERE [ColumnName] = 'NULL' searches for the literal text string 'NULL', not for fields that are actually empty (i.e., have the NULL state).

References

1. PostgreSQL 16 Documentation. (2023). 9.2. Comparison Functions and Operators. In the section detailing comparison operators

it states

"Do not write expression = NULL because NULL is not 'equal to' NULL... To test for nullness

use the constructs IS NULL and IS NOT NULL." Retrieved from postgresql.org/docs/16/functions-comparison.html.

2. Microsoft Transact-SQL (T-SQL) Documentation. (2023). IS NULL (Transact-SQL). Microsoft Learn. This official documentation specifies

"To determine whether an expression is NULL

use IS NULL or IS NOT NULL instead of comparison operators (such as = or !=)." Retrieved from learn.microsoft.com/en-us/sql/t-sql/queries/is-null-transact-sql.

3. Ullman

J. D.

& Widom

J. (n.d.). CS145 Introduction to Databases

Lecture 4: SQL 1. Stanford University. In the lecture slides covering SQL basics

slide 28 ("A Subtlety About NULLs") explicitly states: "Test for NULL using IS NULL and IS NOT NULL

not = or ." Retrieved from web.stanford.edu/class/cs145/slides/04-sql1.pdf.

Scroll to Top