我正在创建一个存储过程,其中我已经使用AS“NameofColumn”方法声明了一个列。现在我想在稍后的存储过程中再次使用该值。反正有吗?
CASE
WHEN ((select top 1 stuksweergeven from componenten where componentid = componentlink.componentid) = 1) and ((select AmountKG from componenten where componentid = componentlink.componentid) <> 0) THEN
Amount * (select AmountKG from componenten where componentid = componentlink.componentid)
ELSE
Amount
END AS Amount
现在我想要做以下
Amount * 10 AS TotalAmount
答案 0 :(得分:0)
使用子查询计算“金额”,然后从该子查询中选择。这样的事情:
select Amount * 10 AS TotalAmount from ( SELECT CASE
WHEN ((select top 1 stuksweergeven from componenten where componentid = componentlink.componentid) = 1) and ((select AmountKG from componenten where componentid = componentlink.componentid) <> 0) THEN
Amount * (select AmountKG from componenten where componentid = componentlink.componentid)
ELSE
Amount
END AS Amount FROM yourtable )e