SQL统计出每个字段里有多少个空值
有A表,字段有a,b,c,d,e,...,z
如何在一个语句里统计出a,b,c,d,e,...,z 的空值字段空值的条数
比如说在一个查询窗口里直接显示出 210,240,500,424,...,500 这样
SELECT IF(A IS NULL,1,0) AS A,IF(B IS NULL ,1,0) AS B ...
FROM TT
是MYSQL?
SELECT SUM(CASE WHEN A IS NULL THEN 1 END)) AS A,SUM( CASE WHEN B IS NULL THEN 1 END)) AS B ...
FROM TT
select sum(a is null),sum(b is null),...sum(z is null)
from 有A表