I'm a little beginner in oracle sql I have a saved...
# suiteql
s
I'm a little beginner in oracle sql I have a saved search that runs a query
Copy code
qty sold   DECODE({item.memberquantity},NULL,{quantity},{quantity}*{item.memberquantity})     stock    DECODE({item.quantityonhand},NULL,{quantity},{quantity}*{item.quantityonhand})
My manager wants to add this stock minus qty sold in one column then column 2 take that answer divide by 12 how can I save the answer in a variable so it won't run 3 times
m
You will have to repeat the formula for each column
s
isnt that really slow
or what about combine inside the decode statement
m
Nah that's not going to affect query speed in any noticeable way
I'm not sure what you mean about combine inside the decode statement, but personally I would rewrite the decode as
{quantity} * NVL({item.memberquantity}, 1)
s
Where could I read how the decide works
Decode