thayduck
asked on
Case Statement Rewrite
select top (@IntTopRecords) m.unit, m.[Year], m.[Make], m.Model, SUM(case when r.rec > 0 then -r.rec else r.Labour + r.Parts + (r.cshop + r.cpart + r.clab) end) as TotalCost
from dbo.Repair r
How would I rewrite above sum(case statement so
if r.ca = 'R' then I want to :
SUM(case when r.rec > 0 then -r.rec else r.Labour + r.Parts + (r.cshop + r.cpart + r.clab) end)
and if r.ca <> 'R' then I want to:
SUM(case when r.rec > 0 then -r.rec else (r.cshop + r.cpart + r.clab) end)
as TotalCost
from dbo.Repair r
How would I rewrite above sum(case statement so
if r.ca = 'R' then I want to :
SUM(case when r.rec > 0 then -r.rec else r.Labour + r.Parts + (r.cshop + r.cpart + r.clab) end)
and if r.ca <> 'R' then I want to:
SUM(case when r.rec > 0 then -r.rec else (r.cshop + r.cpart + r.clab) end)
as TotalCost
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER