Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to count the null values column from table how it is done
suppose the total column is 20 and 10 column is null there is no values in
these column i want count 10.there is no values.
Please help me
thanks
Posted

Specify the column name in the Count function. When count is called with a specific column name, it ignores null.
SQL
SELECT COUNT(Col1) FROM Table1
 
Share this answer
 
SQL
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[^]
 
Share this answer
 
v2
Comments
joti parkash 5-Aug-11 0:41am    
i know that i want to count the column of table where values is null.
your answer will count the rows for particular column
thatraja 5-Aug-11 1:04am    
Check my updated answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900