常用的有两种方法:
1、简单Case函数 :
格式说明
case 列名
when 条件值1 then 选项1
when 条件值2 then 选项2.......
else 默认值 end
2、Case搜索函数
格式说明
case
when 列名= 条件值1 then 选项1
when 列名=条件值2 then 选项2.......
else 默认值 end
本文详细介绍了 SQL 中的 Case 函数,包括简单 Case 函数和 Case 搜索函数的使用方法及格式,帮助读者掌握如何根据不同的条件返回特定的值。
常用的有两种方法:
1、简单Case函数 :
格式说明
case 列名
when 条件值1 then 选项1
when 条件值2 then 选项2.......
else 默认值 end
2、Case搜索函数
格式说明
case
when 列名= 条件值1 then 选项1
when 列名=条件值2 then 选项2.......
else 默认值 end
595
1647

被折叠的 条评论
为什么被折叠?