假设我有一个名为:
的TABLE EMP(Eid,Ename,ESalary)
现在我必须编写一个将更新的查询:
if employee's salary >= 20000 then increment 25% else update 15% salary
答案 0 :(得分:3)
update EMP
set ESalary = CASE WHEN salary >= 20000
THEN salary * 1.25
ELSE salary * 1.15
END;
答案 1 :(得分:0)
试试这个:
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);