dbTalk Databases Forums  

SQL help

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss SQL help in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil Hunt
 
Posts: n/a

Default SQL help - 10-02-2011 , 11:09 AM






How do I count a column that is NULL ?

Thanks

Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: SQL help - 10-02-2011 , 12:52 PM






On Sun, 2 Oct 2011 12:09:08 -0400, "Phil Hunt" <aaa (AT) aaa (DOT) com> wrote:

Quote:
How do I count a column that is NULL ?
Hi Phil,

To count the number of NULL values in a column, use

SELECT SUM(CASE WHEN Column IS NULL THEN 1 ELSE 0 END) FROM YourTable;
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.