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 |
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-02 : 05:09:22
|
I have this statement:COUNT(SesTime)when I check the tables, they're all blanks. Why are blanks being counted? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-02 : 05:19:27
|
is it blanks or space(' ')?. count ignores only NULL values. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-02 : 05:22:54
|
it's blank |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-02 : 05:32:37
|
i got it..it's space (''). Is there a way to ignore the space when counting? thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-02 : 05:42:07
|
quote: Originally posted by cutiebo2t i got it..it's space (''). Is there a way to ignore the space when counting? thanks
try using a NULLIF insideNULLIF(field,' ') |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-02 : 05:47:21
|
it's not actually Null. It's a space. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-02 : 08:59:03
|
quote: Originally posted by cutiebo2t i got it..it's space (''). Is there a way to ignore the space when counting? thanks
Add where clauseWHERE col>''orSELECT sum(case when col>'' then 1 else 0 end) as COUNTING from tableMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-02 : 13:40:30
|
quote: Originally posted by cutiebo2t it's not actually Null. It's a space.
NULLIF(field,' ') will convert space to NULL |
|
|
|
|
|