日期:2014-05-16  浏览次数:20420 次

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)

?

这样就可以排序了