tblEMp
EmpID | Name | Salary | DepID |
---|---|---|---|
1 | Sachin | 1000 | 1 |
2 | Mahora | 2000 | 2 |
3 | Afridi | 3000 | 1 |
tblDep
DepID | DepName |
---|---|
1 | D1 |
2 | D2 |
Now Question is Update Salary with 10% where DepName is D1.and 20% where DepName is D2. Use Join and Single Query Only.
Ans:- update tblemp set Salary = Case tbldep.lname
when 'D1' then Salary +(Salary*0.10)
when 'D2' then Salary +(Salary*0.20)
end
from tblemp join tbldep on tblemp.depid=tbldep.depid