Oracel 中的一些函数

1 substr()与substrb()的区别

   substr()是按字截取
   substrb()是按位(byte)截取

2 sign(变量)

   当变量 大于 0时,返回1;

   当变量 小于 0时,返回-1;

   当变量 等于 0时,返回0;

3 decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)

   当条件 等于 值1 时,返回 翻译值1

   当条件 等于 值2 时,返回 翻译值2

 也就是:

 if 条件=值1 then

     return 翻译值1;

elsif  条件=值2 then

   return 翻译值2;

else

  return 缺省值;

end if;

 

也就是  pl/sql中的case语句
select  (case  when  DUMMY='X'  then  0  else  1  end)  as  flag  from  dual;
case的第1种用法:
case col when 'a' then 1
when 'b' then 2
else 0 end
这种用法跟decode一样没什么区别
case的第2种用法:
case when score <60 then 'd'
when score >=60 and score <70 then 'c'
when score >=70 and score <80 then 'b'
else 'a' end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值