Databricks Certified Data Engineer Associate — Question 86
Identify how the count_if function and the count where x is null can be used
Consider a table random_values with below data.
What would be the output of below query?
select count_if(col > 1) as count_a. count(*) as count_b.count(col1) as count_c from random_values col1
0
1
2
NULL -
2
3
Answer options
- A. 3 6 5
- B. 4 6 5
- C. 3 6 6
- D. 4 6 6
Correct answer: A
Explanation
The correct answer is A because count_if(col > 1) counts the number of rows where col is greater than 1, which is 3. count(*) counts all rows, resulting in 6, and count(col1) counts the non-null entries in col1, which is 5. The other options provide incorrect counts for one or more of these aggregations.