您的位置:首页 > 数据库 > Oracle

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

2012-03-27 18:04 239 查看
表数据;

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: