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.
| Author |
Topic |
|
harlingtonthewizard
Constraint Violating Yak Guru
352 Posts |
Posted - 2008-10-08 : 01:52:31
|
| If I have a result as below how do I count the number of EventCommentID where IS NULL? So result should be 8.EventCommentID1243NULL56NULLNULLNULLNULLNULLNULLNULL |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-08 : 01:55:20
|
| [code]SELECT SUM(CASE WHEN EventCommentID IS NULL THEN 1 ELSE 0 END) AS NullCountFROM Table[/code] |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-10-08 : 06:14:24
|
Hi Visakh, why notSELECT COUNT(*)FROM TableWHERE EventID IS NULL works for me... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-08 : 06:20:53
|
even this will doSELECT COUNT(*)-COUNT(EventID)FROM Table |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-10-08 : 06:39:49
|
Evil one. But my execution plan is shorter. |
 |
|
|
|
|
|