sql 中的case when else
时间: 2023-09-02 17:08:26 浏览: 83
sql学习之CASE WHEN THEN ELSE END的用法
在SQL中,CASE WHEN ELSE是一种条件语句,用于根据条件的不同选择不同的结果。它的基本语法如下:
CASE WHEN condition1 THEN result1
WHEN condition2 THEN result2
ELSE result3
END
在这个语法中,condition1、condition2等是条件表达式,result1、result2等是对应条件的结果。当满足某个条件时,就会返回对应的结果。如果所有条件都不满足,则返回ELSE后面指定的结果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [SQL中case when then else 语句的使用](https://blog.csdn.net/calivnBao/article/details/107782881)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [sql语句中case when then else函数用法](https://blog.csdn.net/My_SweetXue/article/details/109809833)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文