1

假设我有一个名为:

 EMP(Eid,Ename,ESalary)

现在我必须编写一个将更新的查询:

if employee's salary >= 20000 then increment 25% else update 15% salary
4

2 回答 2

3
update EMP
   set ESalary = CASE WHEN salary >= 20000
                      THEN salary * 1.25
                      ELSE salary * 1.15
                      END;
于 2013-04-25T05:12:49.023 回答
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);
于 2013-04-25T05:14:39.757 回答