create table factura (
importe money,
unidades_vendidas int,
subtotal as (unidades_vendidas * importe),
total as (subtotal * 1.18) -- (1.18 needs to be a constant value)
)
如何定义"总计"作为"小计"?
的1.18值答案 0 :(得分:2)
就像错误消息所说的那样,你不能有一个基于另一个计算列的计算列。在你的情况下,绕过它的方法是重做第二个字段中的计算。
create table factura (
importe money,
unidades_vendidas int,
subtotal as (unidades_vendidas * importe),
total as (unidades_vendidas * importe * 1.18)
)
或者,您可以使用触发器为您填充