这是我想要完成的伪代码
我有两个字段:薪水和地区,我有美元到地区的转化次数
如果薪水不为空,那么我想将工资乘以美元乘以基于地区的区域转换
这是伪代码:
substr
有人可以帮帮我吗?
答案 0 :(得分:2)
简单方法:
update table
set salary = salary * 1.58
where region = 'r 1' and salary is not null;
update table
set salary = salary * 1.13
where region = 'r 2' and salary is not null;
使用case的一步:
update table
set salary = case
when region = 'r 1'
then salary * 1.58
when region = 'r 2'
then salary * 1.13
end
where salary is not null
and region in ('r 1', 'r 2');
使用Oracle decode函数:
update table
set salary = salary * DECODE(supplier_id, 'r 1', 1.58,
'r 2', 1.13)
where salary is not null
and region in ('r 1', 'r 2') ;