Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 count

Author  Topic 

renu
Starting Member

47 Posts

Posted - 2007-11-29 : 04:46:47
How to get the count of null values ?

Renu

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-29 : 04:49:54
[code]Select sum(Case when col1 is null then 1 else 0 end) as col1_cnt
from table[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-11-29 : 04:56:10
select count(1) from table where col is null
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-29 : 07:09:31
Different approach

Select count(*)-count(col) from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -