对于这个问题,我需要将雇员数量增加20%,以最低工资(asc订单)开始,直到耗尽100,000美元。我很难找到一个解决方案,如何保存更新的金额,直到使用$ 100,000。这是我迄今为止所拥有的。谢谢Oracle SQL光标增加工资,直到达到最大数量
declare
cursor mancur is
select salary from employees order by salary asc;
tempcur mancur%ROWTYPE;
profits number := 100000;
tempsalary employees.salary%type;
tempinc number(8,2);
begin
open mancur;
loop
fetch mancur into tempcur;
tempinc := tempcur.salary * 1.20;
tempsalary := profits - tempcur.salary;
dbms_output.put_line(tempcur.salary || ' increased by 20% ' || tempinc || ', Bonus amount left ' || tempsalary);
exit when mancur%notfound; --when 100,000 has been used
--update employees set salary = salary * 1.20 where employee_id = tempcur.employee_id;
end loop;
close mancur;
end;
/
这是生产问题还是作业问题?如果它是作业,是PL/SQL类吗?使用单个SQL语句可以更高效地解决此需求。 – mathguy
另外,你如何处理关系?假设你上了名单,现在下一个员工(他们的薪水还没有增加)是三名同样薪水的员工。他们目前的薪水是每人30,000美元,所以他们每人应该得到6,000美元,但只剩下12,000美元。谁得到了多少? – mathguy