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?
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.
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).
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.
Keep practicing
Take the free DA0-002 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DA0-002 practice questions
- Question 1[Data Analysis]A data analyst learns that a report detailing employee sales is reflecting…
- Question 2[Data Analysis]A data analyst is evaluating all conditions in a query. Which of the follo…
- Question 3[Data Analysis]A data analyst creates a report that identifies the middle 50% of the coll…
- Question 4[Data Governance]Which of the following explains the purpose of UAT?
- Question 5[Data Analysis]A product goes viral on social media, creating high demand. Distribution c…
- Question 6[Data Analysis]A data analyst team needs to segment customers based on customer spending …
