case when is null
时间: 2023-10-15 07:22:59 浏览: 186
CASE WHEN is null的作用是在查询结果中对字段进行条件判断,判断字段是否为null,并根据判断结果进行赋值。如果字段的值为null,则可以使用CASE WHEN is null来判断并进行相应的赋值操作。例如,可以使用以下方式来实现从数据表中选择一个字段"field",如果"field"值是1或null,则赋值为1,其它情况为0:
CASE WHEN field = 1 OR field IS NULL THEN 1 ELSE 0 END
这样写可以实现对字段进行条件判断,并根据判断结果进行赋值操作。如果字段的值为1或null,则赋值为1,否则赋值为0。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [使用CASE WHEN语法如何对Null值进行判断](https://blog.csdn.net/zh555888/article/details/129162445)[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 Server CASE语句中关于Null的处理](https://download.csdn.net/download/weixin_38500734/13689907)[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 ]
阅读全文