Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "phil hunt" Newsgroups: comp.databases.ms-sqlserver,microsoft.public.sqlserver.programming Subject: Re: SQL help again Date: Sun, 2 Oct 2011 18:44:03 -0400 Organization: Aioe.org NNTP Server Lines: 28 Message-ID: References: NNTP-Posting-Host: bL8UHSBh4cLkaTSO5EJIWg.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Response X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Priority: 3 X-MSMail-Priority: Normal Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:720 That's it.Thanks. "Bob Barrows" wrote in message news:j6a5n5$9d3$1@dont-email.me... > Phil Hunt wrote: >> I tried >> CASE EventID when NULL then 1 else 0 end >> >> It always return 0, why ? >> >> > Because the way you have the statement structured is causing an equality > comparison to be performed, the result of which will always be false. You > have to structure it like: > > CASE when EventID IS NULL then 1 else 0 end > > To answer your original question, you can subtract the result of > count(distinct column_name) from count(*): > > select count(*) - count(distinct eventid) as null_eventids > > > >