'COUNTing IS NULL returns 0 or with an Error [BigQuery]

I want to find the number of data that is NULL but i do not know why this code returns an error: (Error Message said there was a problem with my WHERE)

SELECT first_review, COUNT (1) AS firstreviewisnull
FROM [table_name]
GROUP BY first_review
WHERE first_review IS NULL

I tried this code and the count returns to 0 - which I know is incorrect:

SELECT COUNT(first_review) AS firstreviewisnull
FROM [table_name]
WHERE first_review IS NULL

If possible, please help to:

  • explain what i did wrong
  • provide with the correct code

thank you!



Solution 1:[1]

Your SQL in the second image seems correct, assuming the [table_name] is actually replaced with the proper table name?

Also, check that the values for first_review are actually null, and not an empty String “”, which is not NULL.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ThreadSurfer