问题是将从事 5 个或 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;