开发者

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

开发者 https://www.devze.com 2023-04-07 08:35 出处:网络
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%.

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


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


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号