DATABRICKS-CERTIFIED-DATA-ENGINEER-ASSOCIATE · Question #34
Which of the following commands will return the number of null values in the member_id column?
The correct answer is C. SELECT count_if(member_id IS NULL) FROM my_table. count_if(condition) is a SQL aggregate function that counts the number of rows where the specified boolean condition evaluates to true. Using count_if(member_id IS NULL) directly counts rows where member_id is NULL, which is exactly the goal. Option A - count(member_id) - is a…
Question
Options
- ASELECT count(member_id) FROM my_table;
- BSELECT count(member_id) - count_null(member_id) FROM my_table;
- CSELECT count_if(member_id IS NULL) FROM my_table;
- DSELECT null(member_id) FROM my_table;
- ESELECT count_null(member_id) FROM my_table;
How the community answered
(27 responses)- A7% (2)
- B4% (1)
- C85% (23)
- E4% (1)
Explanation
count_if(condition) is a SQL aggregate function that counts the number of rows where the specified boolean condition evaluates to true. Using count_if(member_id IS NULL) directly counts rows where member_id is NULL, which is exactly the goal. Option A - count(member_id) - is a common trap: SQL's count() function ignores NULL values by design, so it returns the count of non-null rows, not null rows. count_null() and null() are not valid standard SQL functions. Option B mixes valid and invalid functions.
Topics
Community Discussion
No community discussion yet for this question.