Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

thank you!

>Solution :

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

Count() function ignores Null values (it does not count them). Use count(*) if you want to count the rows where girst_review is null.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading