Posted by mike on 10/25/06 18:30
I have a question on coding, just want to see if there is a better way
to do this.
Here is some sample data combinations that would come from 2 different
tables.
Item Method Price Cost Percentage
A-1 L 100 50 10
A-2 D 110 55 15
A-3 U 90 40 65
Ok, here is what I want to do.
If L then 100 x (1+(10/100))
if D then 110 x (1-(15/100))
if U then 40 x (1+(65/100))
To produce 1 number per item.
I can do this obviously using multiple When Then Else statements.
Like
Case when method='L'
then Price * (1+(percentage/100))
else case when method='D'
then Price * (1-(percentage/100))
else Cost * (1+(percentage/100))
end
end
However I was thinking there might just be a better way to do this that
I am not familar with, plus I could easily have 8-10 of these methods
that I need to code.
Any ideas on a better way?
Thanks in advance.
Navigation:
[Reply to this message]
|