DA0-002 Data Concepts and Environments Practice Question
A healthcare organization maintains a database of patient records. The database has a table 'patients' with columns: patient_id (primary key), first_name, last_name, date_of_birth, gender, and last_visit_date. A data analyst is tasked with creating a report that lists all patients who have not visited in the last two years. The analyst writes a query: SELECT * FROM patients WHERE last_visit_date < DATEADD(year, -2, GETDATE()); However, the query returns zero rows, even though the analyst knows there are patients who have not visited for over two years. Upon inspection, the analyst discovers that the last_visit_date column contains NULL values for patients who have never visited. Which modification to the query should the analyst make to include patients with NULL last_visit_date?
⚠ Common exam trap
The trap here is that candidates often forget that NULL comparisons in SQL do not return TRUE, leading them to incorrectly think the original query already handles NULLs, and they may choose Option C (COALESCE) as a workaround instead of the simpler and correct IS NULL check.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Add OR last_visit_date IS NULL to the WHERE clause.
The original query uses a WHERE clause that compares last_visit_date to a computed date, but NULL comparisons in SQL always yield UNKNOWN, so rows with NULL last_visit_date are excluded. Adding OR last_visit_date IS NULL explicitly includes those rows, ensuring patients who have never visited are listed in the report.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Remove the WHERE clause entirely.
Why it's wrong here
Returns all patients, not just those not visited.
- ✓
Add OR last_visit_date IS NULL to the WHERE clause.
Why this is correct
Includes NULLs in the result.
- ✗
Use COALESCE(last_visit_date, '1900-01-01') in the WHERE clause.
Why it's wrong here
COALESCE could work but may not be intuitive and depends on the replacement value.
- ✗
Add AND last_visit_date IS NOT NULL to the WHERE clause.
Why it's wrong here
This excludes NULLs, making the problem worse.
Go deeper
Related to this question
About these practice questions
This DA0-002 question is part of Courseiva's 986-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DA0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DA0-002 exam.