我想查找為 NULL 的資料數,但我不知道為什么此代碼回傳錯誤:(錯誤訊息說我的 WHERE 有問題)
SELECT first_review, COUNT (1) AS firstreviewisnull
FROM [table_name]
GROUP BY first_review
WHERE first_review IS NULL
我嘗試了這段代碼,計數回傳 0 - 我知道這是不正確的:
SELECT COUNT(first_review) AS firstreviewisnull
FROM [table_name]
WHERE first_review IS NULL
如果可能,請幫助:
- 解釋我做錯了什么
- 提供正確的代碼
謝謝!
uj5u.com熱心網友回復:
SELECT COUNT(*) AS firstreviewisnull
FROM [table_name]
WHERE first_review IS NULL
Count() 函式忽略 Null 值(它不計算它們)。如果要計算 girst_review 為空的行數,請使用 count(*)。
uj5u.com熱心網友回復:
假設 [table_name] 實際上已替換為正確的表名,您在第二張圖片中的 SQL 似乎是正確的?
此外,檢查 first_review 的值是否實際上為空,而不是空字串“”,它不是 NULL。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/422484.html
標籤:
