我有一个名为 @status 的变量,我在此 select 语句之前设置了它:
Select
ordr_num as num,
ordr_date as date,
ordr_ship_with as shipwith
From
order
where ordr_num = @ordrNum
我只想选择ordr_ship_with
列如果@status <> 'Cancelled'
,否则我想为shipwith选择null。我该如何实现这个目标?
SELECT ordr_num as num, ordr_date as date,
CASE WHEN @status<>'Cancelled' THEN ordr_ship_with ELSE NULL END as shipwith
FROM order
WHERE ordr_num = @ordrNum
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)