oracle里面如何写case语句

 http://doc.linuxpk.com/49161.html

 

如下:

  SELECT LogID,UserID,LogTime,Url,Description,(case OperateType when OperateType = 0 then '新增' when OperateType=1 then '修改' else '删除' end case) FROM LOG

  1. case

  SELECT LogID,UserID,LogTime,Url,Description,(

  case

  when OperateType = 0

  then '新增'

  when OperateType=1

  then '修改'

  else '删除'

  end ) FROM LOG

  2.DECODE的写法:

  SELECT LogID,UserID,LogTime,Url,Description,

  decode(OperateType,0,'新增',1,'修改','删除') OperationName

  FROM LOG

  建议用DECODE的写法

 

如何使用Oracle的Decode函数进行多值判断

 


Decode函数的语法结构如下:

decode (expression, search_1, result_1)
decode (expression, search_1, result_1, search_2, result_2)
decode (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n)

decode (expression, search_1, result_1, default)
decode (expression, search_1, result_1, search_2, result_2, default)
decode (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n, default)

decode函数比较表达式和搜索字,如果匹配,返回结果;如果不匹配,返回default值;如果未定义default值,则返回空值。

你可能感兴趣的:(oracle,url,search)