假设我有一个名为:
EMP(Eid,Ename,ESalary)
现在我必须编写一个将更新的查询:
if employee's salary >= 20000 then increment 25% else update 15% salary
假设我有一个名为:
EMP(Eid,Ename,ESalary)
现在我必须编写一个将更新的查询:
if employee's salary >= 20000 then increment 25% else update 15% salary
update EMP
set ESalary = CASE WHEN salary >= 20000
THEN salary * 1.25
ELSE salary * 1.15
END;
尝试这个:
update emp a set esalrary =
(select (case when esalary >=20000 then esalary+(esalary*25/100)
else esalary+(esalary*25/100) end) from emp b where a.eid=b.eid);