October 7, 2010 at 6:55 am
How can I combine the select clauses so the if order type='1' has a value of 2 and there are no order2 code='3' the answer will be 2 not null. if order2 code='3' has a value of 4 then I get the correct result of 6.
Thanks
October 7, 2010 at 7:39 am
Is it me or there's a better way to describe this problem?
I don't think I understand what you're after.
Can you explain?
-- Gianluca Sartori
October 7, 2010 at 7:43 am
try:
set @t1=IsNull((select sum(a) from order where type='1'),0) + IsNull((select sum(b) from order2 where code='3'),0)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
October 7, 2010 at 7:50 am
WayneS (10/7/2010)
try:
set @t1=IsNull((select sum(a) from order where type='1'),0) + IsNull((select sum(b) from order2 where code='3'),0)
... ok, it was me! 🙂
-- Gianluca Sartori
October 7, 2010 at 8:17 am
Thanks. That did it.
I was close to what you had but must have missed a period somewhere and we all know what happens when that happens.;-)
October 7, 2010 at 8:30 am
Gianluca Sartori (10/7/2010)
WayneS (10/7/2010)
try:
set @t1=IsNull((select sum(a) from order where type='1'),0) + IsNull((select sum(b) from order2 where code='3'),0)
... ok, it was me! 🙂
:w00t::hehe::-P
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply