sqlserver case使用方法

2023-10-17 15:35:14 浏览数 (2)

sqlserver case使用方法

实例

代码语言:javascript复制
SELECT kehubianhao,CASE 
WHEN ContractDate <= '2022-05-22' THEN '0'
WHEN ContractDate > '2022-05-1' THEN '1'
ELSE '3'
END 'value'
from   dbo.Affter_Entry
WHERE XMXQBHCC IN ('*','*') AND  kehubianhao='******************' 
AND  SYS_Deleted='0' 

注: WHEN ContractDate <= ‘2022-05-22’ THEN ‘0’ WHEN 条件满足显示THEN 后边的值 END ‘value’ 给加的这一列起名

结果展示

0 人点赞