問題は、5 つ以上のプロジェクトに携わった全従業員の給与を 50%、30% (>= 3 つのプロジェクト)、20% (>= 1 つのプロジェクト) で更新するプロジェクトの数です。 EMPLOYEE_PROJECT_HISTORY に対してグループごとのクエリを実行する。
私はこれらのクエリを試しました
update emp set emp.sal=
case
when jemp.pcount >=5 then emp.sal+ (emp.sal*50)/100
when jemp.pcount >=3 then emp.sal+ (emp.sal*30)/100
when jemp.pcount >=1 then emp.sal+ (emp.sal*20)/100
else emp.sal+ (emp.sal*20)/100
end
from employee emp join (select empno as jempno,count(projectno) as pcount from EMPLOYEE_PROJECT_HISTORY by empno) jemp on emp.empno=jemp.jempno ;
update employee a set a.sal= case (select count(b.projectno) as pcount from EMPLOYEE_PROJECT_HISTORY b group by b.empno )
when b.pcount >5 then
a.sal = a.sal+ (a.sal*50)/100
when pcount >3 then
a.sal = a.sal+ (a.sal*30)/100
when pcount >1 then
a.sal = a.sal+ (a.sal*20)/100
end;