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!
CodePudding user response:
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.
CodePudding user response:
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.
