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 |
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-06-18 : 10:32:24
|
HiI have the following piece of QueryISNULL(SUM(CASE WHEN NULLIF (TID, '0') IS NULL THEN Qty END), 0) AS QtyBooks This works fine when TID is null or '0', but I also need to add (TID = ''), how do I add that check? |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-06-18 : 10:42:37
|
what about:select isnull(sum(Qty), 0) AS QtyBooksfrom ...yourtable...where TID in ('0', '') |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-06-18 : 10:52:36
|
I cant do that beacuse I have Another condition almost like the one I posted that do Another Count. I Think I need to have the condition within the exsisting one.... |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-06-18 : 10:55:36
|
OK then:ISNULL(SUM(CASE WHEN TID IN ('0', '') THEN Qty END), 0) AS QtyBooks |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-06-18 : 11:00:47
|
Awsome, thanks! |
|
|
|
|
|