SELECT PrisID,
Navn,
[Vægt (g)],
[RåvarePris(øre)],
Produktionsomk,
[RåvarePris(øre)] + Produktionsomk AS NettoPris,
NettoPris * 25 AS Moms,
NettoPris + Moms AS PrisInclMoms,
PrisInclMoms * 100 AS [Pris(100gr)]
FROM PrislisteBolsjer
答案 0 :(得分:3)
您不能在创建的同一个字段列表中使用别名。
您可以使用cross apply
进行需要重复使用的计算。
SELECT PrisID,
Navn,
[Vægt (g)],
[RåvarePris(øre)],
Produktionsomk,
T1.NettoPris,
T2.Moms,
T3.PrisInclMoms,
T3.PrisInclMoms * 100 AS [Pris(100gr)]
FROM PrislisteBolsjer
CROSS APPLY (SELECT [RåvarePris(øre)] + Produktionsomk) AS T1(NettoPris)
CROSS APPLY (SELECT T1.NettoPris * 25) AS T2(Moms)
CROSS APPLY (SELECT T1.NettoPris + T2.Moms) AS T3(PrisInclMoms)