I have emp table with 3 columns: emp_no, salary and remaining_salary. I have a total 1000 to begin with. Now, I like a loop to update (like update emp set remaining_salary = 1000- salary ) to display the following the result data. When comes to 0 then exit. How to do this in a for loop? Thanks.
emp_no salary remaining_salary
1 300 700
2 400 300
3 500 0
4 600 0
Start Free Trial