QuestionQ175

VerifiedData Processing & Transformations

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

Explanation

count_if(col > 1) counts rows where col is greater than 1 (values 2, 2, 3 = 3 rows); count(*) counts all rows including NULL (6 total); count(col) counts only non-NULL values (0, 1, 2, 2, 3 = 5 rows). The output is 3, 6, 5.

Community Discussion

No comments yet. Be the first to start the discussion!