在我的存储过程中,我现在尝试将FEE添加到我的销售中。
我尝试将其添加到我的SELECT语句中,但是我不知道如何正确插入它。
AS 'Income inc VAT, ex Discount',
case when item_price > 69 then 6
case when item_price <= 69 then 3
else 1
AS 'fee'
为了举例说明我如何尝试实现它,我添加了一些select语句...
解决方案:在我的select语句中,我根据获得的出色答案添加了此代码,并且它的工作原理是:
case when item_price > 69 then 6
when item_price <= 69 then 3
else 1
end
AS 'Fee'
您应该使用案例陈述:
从内存写入:
insert into fee (fee_value)
select
case when item_price > 69 then 6
case when item_price <= 69 then 3
else 1
end
等等...
或者,也许您想使用变量:
declare @fee int
if @item_price > 69
set @fee = 6
...
insert into fee(fee_value)
values (@fee)
或另一种方式:
declare @item_price int = 12
declare @fee int
SELECT
@fee = case
when @item_price > 69 then 6
when @item_price between 13 and 69 then 2
else 1
end
select @fee
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句