oracle中能否写判断语句

求此在ORCALE中如此写这条语句,能够实现此目的。THANKS
2024-12-03 06:06:53
推荐回答(3个)
回答1:

如果是select查询做显示的话
select code,
name,
case when length(code) =3 then 1
when length(code)=6 then 2
when length(code)=9 then 3
end id
from table;
如果是要插入的话
update table set id =(
case when length(code) =3 then 1
when length(code)=6 then 2
when length(code)=9 then 3
end)

回答2:

update 表名
set id=(case when length(code) = 3 then
1
when length(code) = 6 then
2
when length(code) = 9 then
3
end)

回答3:

select case when length(code) = 3 then 1 when length(code) = 6 then 2 when length(code) = 9 then 3 end ID
from tab

是这样吗?