Comments and answers for "How can i calculate a formular was stored in sql ?"
https://ask.sqlservercentral.com/questions/135073/how-can-i-calculate-a-formular-was-stored-in-sql.html
The latest comments and answers for the question "How can i calculate a formular was stored in sql ?"Comment by clickhere on clickhere's answer
https://ask.sqlservercentral.com/comments/135098/view.html
Thanks Tom, In this case, the TURNOVER_FORMULAR depend on STK_CODE value. Can i use CURSOR when my data over 10.000 records for every processWed, 11 Nov 2015 07:44:17 GMTclickhereAnswer by Tom Staab
https://ask.sqlservercentral.com/answers/135082/view.html
You can use a computed column, but your formula is different on each line, and I don't know the exact rules. The formula to combine all of those variations will be a bit complicated, but it would probably be something like this.
ALTER TABLE MyTable
ADD turnover_formular AS
CASE
WHEN incoming_quantity > 1000
THEN total_freight * .5 + incoming_quantity * 1000
WHEN incoming_quantity BETWEEN 1 AND 1000
THEN total_freight * .5 + incoming_quantity * 5000
WHEN incoming_quantity = 0 AND outgoing_quantity > 0
THEN outgoing_weight * 1000 + outgoing_quantity * 500
ELSE total_freight * .45
END
;Tue, 10 Nov 2015 21:49:18 GMTTom Staab