user1097946
user1097946

Reputation: 3

Formula isn't working in computed column

I am using SQL Server management studio. I have a column named salary. I want another computed column based on salary: (salary *20%+salary)/85 but I don't get the result.

I tried putting the formula in computed column specification tab under properties tab.

Upvotes: 0

Views: 152

Answers (2)

Taryn
Taryn

Reputation: 247700

You should be able to use the following to calculate the value:

(salary * 1.2) / 85

See a SQL fiddle demo

Upvotes: 2

Curtis
Curtis

Reputation: 103358

That is an invalid SQL computation.

Instead of multiplying by percentage, divide by 100 and multiply by the percentage value:

(((salary/100)*20)+salary)/85

Upvotes: 2

Related Questions