Databricks-DA-Assoc Executing Queries with Databricks SQL Practice Question
A data analyst runs a query in Databricks SQL that aggregates sales data by product category. The analyst notices that the query results include a category value of NULL. The analyst wants to exclude rows where the category is NULL from the aggregation. Which SQL clause should be added to the query?
⚠ Common exam trap
The trap here is using HAVING instead of WHERE to filter NULLs; HAVING filters after aggregation and does not prevent the aggregation from processing NULL rows, which can be less efficient and may still include the NULL group if not properly filtered.
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
✓
WHERE category IS NOT NULL
To exclude NULL categories before aggregation, use a WHERE clause with IS NOT NULL. This filters out rows with NULL category before grouping, so the aggregation does not include a NULL group. HAVING filters after aggregation and is less efficient, while ORDER BY only sorts.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
WHERE category IS NOT NULL
Why this is correct
The WHERE clause filters rows before aggregation, so adding WHERE category IS NOT NULL removes rows with NULL category from the input to the aggregation. This ensures the aggregation does not include NULL as a group. It is the correct way to exclude NULLs before grouping.
- ✗
ORDER BY category NULLS LAST
Why it's wrong here
ORDER BY with NULLS LAST only affects the order of rows in the result set; it does not remove NULL categories from the aggregation. The NULL group would still be present. This clause is for sorting, not filtering.
- ✗
GROUP BY category HAVING COUNT(*) > 0
Why it's wrong here
This HAVING condition filters groups with zero rows, which is not possible; every group has at least one row. It does not exclude NULL categories. The NULL category would still appear if it has rows. This does not address the requirement.
- ✗
HAVING category IS NOT NULL
Why it's wrong here
The HAVING clause filters after aggregation and can only reference aggregated columns or columns in the GROUP BY. Although you can use HAVING category IS NOT NULL if category is in the GROUP BY, it is less efficient because the aggregation still processes NULL rows. The WHERE clause is more appropriate for filtering rows before aggregation.
About these practice questions
This Databricks-DA-Assoc question is part of Courseiva's 291-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Databricks exam blueprint
This Databricks-DA-Assoc practice question is part of Courseiva's free Databricks 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 Databricks-DA-Assoc exam.