
Answer-first summary for fast verification
Answer: | age | country | |-----|---------| | 80 | canada | | 75 | canada | | 90 | canada |
**Option A:** | age | country | |------|---------| | 80 | canada | | NULL | canada | | 90 | NULL | **Incorrect.** - The row with `age = NULL` fails `age >= 75` (NULL comparisons return unknown/false in the WHERE clause). - The row with `country = NULL` fails `country = 'canada'`. - This output includes rows that violate the WHERE conditions. **Option B:** | age | country | |-----|---------| | 80 | NULL | | 75 | NULL | | 90 | NULL | **Incorrect.** - All rows have `country = NULL`, which does **not** equal `'canada'`. - The WHERE clause requires `country = 'canada'`, so these rows should be filtered out entirely. **Option C:** | id | age | country | |------|-----|---------| | 900 | 80 | canada | | 901 | 75 | canada | | 902 | 90 | canada | **Incorrect.** - The query selects **only** `age` and `country`. It does **not** include the `id` column. - Even if the data were correct, the output table structure is wrong. **Option D:** | age | country | |-----|---------| | 80 | canada | | 14 | canada | | 90 | canada | **Incorrect.** - The row with `age = 14` fails the condition `age >= 75`. - The WHERE clause should remove any row where age is less than 75. **Option E:** | age | country | |-----|---------| | 80 | canada | | 75 | canada | | 90 | canada | **Correct.** - All rows satisfy **both** `age >= 75` **and** `country = 'canada'`. - Only the requested columns (`age` and `country`) are returned. - No extra columns, no rows with age < 75, and no NULLs that would fail the filter. ### Reference Answer **The correct answer is E.** This question tests fundamental SQL concepts: - How the **WHERE** clause with **AND** works (both predicates must be true). - What columns are actually projected by the **SELECT** clause. - Behavior of **NULL** values in filters (they are excluded). Mastering these basics is essential for the Databricks Certified Data Analyst - Associate exam, as many questions revolve around correct SQL filtering, projection, and understanding query output structure. Keep practicing similar queries by mentally applying the WHERE conditions to sample data!
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A data analyst runs the following command:
SELECT age, country -
FROM my_table -
WHERE age >= 75 AND country = 'canada';
SELECT age, country -
FROM my_table -
WHERE age >= 75 AND country = 'canada';
Which of the following tables represents the output of the above command?
A
| age | country |
|---|---|
| 80 | canada |
| NULL | canada |
| 90 | NULL |
B
| age | country |
|---|---|
| 80 | NULL |
| 75 | NULL |
| 90 | NULL |
C
| id | age | country |
|---|---|---|
| 900 | 80 | canada |
| 901 | 75 | canada |
| 902 | 90 | canada |
D
| age | country |
|---|---|
| 80 | canada |
| 14 | canada |
| 90 | canada |
E
| age | country |
|---|---|
| 80 | canada |
| 75 | canada |
| 90 | canada |