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