oracle中有没有类似于sqlserver中的case 内置函数
问题:
A、 表中有 id,a1,a2,b1,b2,c1,c2,k 字段
依据条件if b1 - a1 <-k then c1= b1 - a1 else c1=a1 -b1 end if;
if b2 - a2 <-k then c2=b2- a2 else c2=a2 -b2 end if;
更新表中的 c1,c2
问题:
A、 表中有 id,a1,a2,b1,b2,c1,c2,k 字段
依据条件if b1 - a1 <-k then c1= b1 - a1 else c1=a1 -b1 end if;
if b2 - a2 <-k then c2=b2- a2 else c2=a2 -b2 end if;
更新表中的 c1,c2
如果是<=k
update table set
c1 = decode(sign(b1-a1-k), 1, a1-b1, b1-a1),
c2 = decode(sign(b2-a2-k), 1, a2-b2, b2-a2)
you can use "case" just like in ms sql