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 answers for the question "How can i calculate a formular was stored in sql ?"Answer 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