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’ 给加的这一列起名
结果展示