是否可以改善以下内容?我需要计算特定列中具有NULL
个值的所有行。
SELECT
SUM(IF(column1 IS NULL, 1, 0)) AS column1,
SUM(IF(column2 IS NULL, 1, 0)) AS column2
FROM
`dataset.table`;
答案 0 :(得分:3)
其中一个选项:
#standardSQL
SELECT
COUNTIF(column1 IS NULL) AS column1,
COUNTIF(column2 IS NULL) AS column2
FROM `project.dataset.table`
或者(只是为您提供一些选择):
#standardSQL
SELECT
COUNT(1) - COUNT(column1) AS column1,
COUNT(1) - COUNT(column2) AS column2
FROM `project.dataset.table`