sql Server 查询出表中一个字段为空的数量
答案:5 悬赏:60 手机版
解决时间 2021-04-08 01:35
- 提问者网友:且恨且铭记
- 2021-04-07 09:34
sql Server 查询出表中一个字段为空的数量
最佳答案
- 五星知识达人网友:轻熟杀无赦
- 2021-04-07 10:02
--计算为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
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
全部回答
- 1楼网友:雪起风沙痕
- 2021-04-07 13:09
is dbnull
- 2楼网友:一把行者刀
- 2021-04-07 11:54
where address=''追问你这没写完吧?追答Select * from table where address=''
我以为不用写那么详细
我以为不用写那么详细
- 3楼网友:蓝房子
- 2021-04-07 11:32
首先你要说清楚是空字符还是无值。
空字符:address=‘’
无值:address is null
都算就加or关系追问空字符跟无值,都算追答就这样: (address=‘’ or address is null)
空字符:address=‘’
无值:address is null
都算就加or关系追问空字符跟无值,都算追答就这样: (address=‘’ or address is null)
- 4楼网友:怀裏藏嬌
- 2021-04-07 11:13
因为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
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯