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) |