oracle 替代 case when
时间: 2023-08-26 12:13:37 浏览: 133
如何使用CASE WHEN语法判断入参代替if test=user-name != null and user-name !=
在Oracle中,你可以使用"decode"函数来替代"case when"语句。"decode"函数接受一个表达式和多个条件和结果对,根据表达式的值返回对应的结果。以下是一个示例:
select a.id, decode(a.name, 'zhangming', '张明', 'mingzhang', '张明', null), a.grade from user a
在上述示例中,我们使用"decode"函数来替代"case when"语句。当a.name等于'zhangming'时,返回'张明',当a.name等于'mingzhang'时,也返回'张明',否则返回null。这样就实现了和"case when"相同的逻辑。
引用和提供了一些关于"case when"语句和"decode"函数的用法注意事项。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* [【Oracle】替换语句:replace,case-when-then-else-end语句](https://blog.csdn.net/River_Continent/article/details/80968402)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [Oracle中的case when以及decode](https://blog.csdn.net/wuChiSha/article/details/109626772)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文