Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #711

Re: SQL help

From Hugo Kornelis <hugo@perFact.REMOVETHIS.info.INVALID>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Re: SQL help
Date 2011-10-02 19:52 +0200
Message-ID <d69h87t5vh4hodgnrma44bv5vdlp4s4nlv@4ax.com> (permalink)
References <j6a2b1$2kf$1@speranza.aioe.org>

Cross-posted to 2 groups.

Show all headers | View raw


On Sun, 2 Oct 2011 12:09:08 -0400, "Phil Hunt" <aaa@aaa.com> wrote:

>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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

SQL help "Phil Hunt" <aaa@aaa.com> - 2011-10-02 12:09 -0400
  Re: SQL help Hugo Kornelis <hugo@perFact.REMOVETHIS.info.INVALID> - 2011-10-02 19:52 +0200

csiph-web