sql Server 查询出表中一个字段为空的数量

2025-02-24 17:29:41
推荐回答(5个)
回答1:

因为count统计语句是统计不出null的,所以用

select count(address) from test where address is null

得出的结果一定是0,知道了原因,相应的解决办法就有了,可以统计不为空的列,假如name列不可以为空,每一行都有数据,那么可以用下面的语句来查询

select count(name) from test where address is null and name is not null

回答2:

--计算为null的个数
select count(*) from table where address is null
--计算长度为0的个数
select count(*) from table where address=''
--计算为null或长度为0的个数
select count(*) from table where address='' or address is null

回答3:

首先你要说清楚是空字符还是无值。
空字符:address=‘’

无值:address is null
都算就加or关系

回答4:

is dbnull

回答5:

where address=''