Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IIF functionality in a Select Statement
Message
From
28/09/2000 17:54:31
 
 
To
28/09/2000 17:37:52
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00422326
Message ID:
00422341
Views:
12
>I have the folling select statment operating in the odbc to fox world.
>I need to do the same thing with oledb to SQL tables now. I cannot find the correct syntax. Any suggestions?
>
>SELECT
> sum(iif(ordh.rebid_cost>0,ordh.rebid_cost,ordh.bid_cost)) as tot_bid_cost
>FROM ordh left join ordd on ordh.co_number=ordd.co_number
>GROUP by ordd.prom_dlvry
>
>
>
>I understand that I should be using a case statement instead of IIF....but how do you do a sum with a case statement?

You have to use a case statement:

SELECT
sum(case
when ordh.rebid_cost>0 then orhd.rebid_cost
else ordh.bid_cost
end) as tot_bid_cost
FROM ordh
left join ordd
on ordh.co_number=ordd.co_number
GROUP by ordd.prom_dlvry


BOb
Previous
Reply
Map
View

Click here to load this message in the networking platform