计算表中的空值列 [英] count null values column from table

查看:80
本文介绍了计算表中的空值列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从表中计算空值列的完成方式
假设total列为20,而10列为null,则
中没有值 这些列我想算10.没有值.
请帮帮我
Thanks

解决方案

Count函数中指定列名.当使用特定的列名调用count时,它将忽略null.

  SELECT  COUNT(Col1) FROM  Table1 


  SELECT  COUNT(ColumnName)> FROM  TableName 位置 ColumnName  IS   NULL  



编辑
----------------------
我看错了.

嗯....您可以计算表中的列,但我不知道是否可以选择对空列进行计数(我的意思是基于空值).
计算每个表中的列数 [ ^ ]
使用此方法,您可以计算NULL& NOT NULL列(您需要在查询中进行一些更改)
在SQL Server 2005中,如何计算表中的列数? [ ^ ]
计数非空白列 [ 解决方案

Specify the column name in the Count function. When count is called with a specific column name, it ignores null.

SELECT COUNT(Col1) FROM Table1


SELECT COUNT(ColumnName) FROM TableName WHERE ColumnName IS NULL



EDIT
----------------------
I misread that.

hmm....you can count the columns in the table but i don''t know if there is option to count null columns(I mean based on null values).
Count the number of columns in each TABLE[^]
Using this you can count NULL & NOT NULL columns(You need to do some changes in query)
In SQL Server 2005, how do you count the number of COLUMNS in a table?[^]
Counting non-blank columns[^]


这篇关于计算表中的空值列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆