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


Groups > comp.databases.ms-sqlserver > #701 > unrolled thread

SQL help

Started by"Phil Hunt" <aaa@aaa.com>
First post2011-10-02 12:09 -0400
Last post2011-10-02 19:52 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.databases.ms-sqlserver


Contents

  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

#701 — SQL help

From"Phil Hunt" <aaa@aaa.com>
Date2011-10-02 12:09 -0400
SubjectSQL help
Message-ID<j6a2b1$2kf$1@speranza.aioe.org>
How do I count a column that is NULL ?

Thanks 

[toc] | [next] | [standalone]


#711

FromHugo Kornelis <hugo@perFact.REMOVETHIS.info.INVALID>
Date2011-10-02 19:52 +0200
Message-ID<d69h87t5vh4hodgnrma44bv5vdlp4s4nlv@4ax.com>
In reply to#701
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-sqlserver


csiph-web