對於這個問題,我需要將僱員數量增加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