首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

oracle的decode步骤

2012-07-05 
oracle的decode方法用法实例如下:?select?? decode(x,1,x is 1,2,x is? 2,others)? from? dual??当x

oracle的decode方法

用法实例如下:

?

select?? decode(x,1,'x is 1',2,'x is? 2','others')? from? dual

?

?

当x? 是1 时,则返回 ‘x? is 1’

?

当 x 是2 时,则返回 ‘x? is 2’

?

否则的话,则返回 ‘others’

?

?

再如:?? a? 表按照语数外进行排序

?

?

select? *? from?? a? order? by? decode(km,'语文',1,'数学',2,'外语',3)

?

这样就可以排序了

热点排行