SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 additional case
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

magmo
Aged Yak Warrior

524 Posts

Posted - 06/18/2014 :  10:32:24  Show Profile  Reply with Quote
Hi

I have the following piece of Query


ISNULL(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
Flowing Fount of Yak Knowledge

1109 Posts

Posted - 06/18/2014 :  10:42:37  Show Profile  Reply with Quote
what about:


select isnull(sum(Qty), 0) AS QtyBooks
from ...yourtable...
where TID in ('0', '')
Go to Top of Page

magmo
Aged Yak Warrior

524 Posts

Posted - 06/18/2014 :  10:52:36  Show Profile  Reply with Quote
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....
Go to Top of Page

gbritton
Flowing Fount of Yak Knowledge

1109 Posts

Posted - 06/18/2014 :  10:55:36  Show Profile  Reply with Quote
OK then:


ISNULL(SUM(CASE WHEN TID IN ('0', '') THEN Qty END), 0) AS QtyBooks
Go to Top of Page

magmo
Aged Yak Warrior

524 Posts

Posted - 06/18/2014 :  11:00:47  Show Profile  Reply with Quote
Awsome, thanks!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000