setting a return value
Posted on 2005-05-03
I am trying to get a value to return based on a formula - this is my query
select warehouse,product,quantity,date,customer,value ,cost,
(case when cost=0 then margin=100 else (sum( ((value-cost)/cost)*100) as margin) end
group by warehouse,product,quantity,date,customer,value ,cost
basically I need to find the value of margin - but as sometimes the cost field might have a zero value I need to say margin=100 - however my query shown above gives an error. Any ideas what I am doing wrong?