oracle查询sql练习技巧(这个很实用,不是吹的)

表数据;

MENU_IDIS_TREE
00011
00021
01012
0102
0103
02015
02026

--------------使用decode函数
select b.menu_id,decode(b.is_tree,'1','1vv','2','2vv',null,'isnullvalue','defaultvaluehehe') tree 
from menutree b

--------------使用case when then else达到相同效果
select c.menu_id,
case
when c.is_tree is null then 'isnullvalue'
when c.is_tree='1' then '1vv'
when c.is_tree='2' then '2vv'
else 'defaultvaluehehe' 
end tree 
from menutree c


上面2个sql效果是一样的。

MENU_IDTREE
00011vv
00021vv
01012vv
0102isnullvalue
0103isnullvalue
0201defaultvaluehehe
0202defaultvaluehehe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值