Fahad Hussain
Fahad Hussain

Reputation: 1185

How to update a field of a table with some percentage of its value in SQL?

Let suppose I have a table Employee, which have three field i.e EID , Salary, Dept

What I want to do is to increase the salary of every employee of Department 'Accounts' by 5%.

How this could be achieved in SQL Sever Query?

Kindly help me out!

Cheers

Upvotes: 4

Views: 21567

Answers (2)

Iridio
Iridio

Reputation: 9271

you can simply create an update statement with the right math. I would do something like this:

 update Employee set salary = (salary * 1.05) where Dept = 'Accounts'

Upvotes: 8

Royi Namir
Royi Namir

Reputation: 148744

update Mytable set Sal=1.05*sal where departmentId=xxx

Upvotes: 11

Related Questions