Sql server 使用常量文字从另一个计算列创建计算列
如何将“总计”定义为“小计”的1.18值?正如错误消息所说,不能基于另一个计算列创建计算列。在您的案例中,解决这个问题的方法是在第二个字段中重新计算Sql server 使用常量文字从另一个计算列创建计算列,sql-server,Sql Server,如何将“总计”定义为“小计”的1.18值?正如错误消息所说,不能基于另一个计算列创建计算列。在您的案例中,解决这个问题的方法是在第二个字段中重新计算 create table factura ( importe money, unidades_vendidas int, subtotal as (unidades_vendidas * importe), total as (subtotal * 1.18) -- (1.18 needs to be a
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)
)
或者,您可以使用触发器来为您填充它
create table factura (
importe money,
unidades_vendidas int,
subtotal as (unidades_vendidas * importe),
total as (unidades_vendidas * importe * 1.18)
)