I have a table in a SQL Server database and Excel that looks like this
Using Excel to calculate the value of "D" in column "H" I have used the following formula:
=IF(G2="NULL",100,IF(A2="NULL",((E2-3-F2)/D2),IF(D2="NULL",((B2-3-C2)/A2),IF(((B2-3-C2)/A2)<((E2-3-F2)/D2),((B2-3-C2)/A2),((E2-3-F2)/D2)))))
The formula works fine and if I want to change the value 3 to 3.2 in the formula and update the values in Excel, I just change 3 to 3.2 to make it look like the formula below:
=IF(G2="NULL",100,IF(A2="NULL",((E2-3.2-F2)/D2),IF(D2="NULL",((B2-3.2-C2)/A2),IF(((B2-3.2-C2)/A2)<((E2-3.2-F2)/D2),((B2-3.2-C2)/A2),((E2-3.2-F2)/D2)))))
However I don't know how to convert this Excel formula to a SQL query and I would appreciate if anyone can help me in writing the correct SQL query statement based on the above formula. Thanks in advance.