当我得到
时,如何将结果传递给另一个计算无效的列名称profilhøjde
这样做的正确方法是什么?
select * from
(select ([brede]*[Profil])/100 as "profilhøjde"
from [Tabel].[dæk]
)a
select * from
(select ("profilhøjde" *2 + @diameter10)*PI() as "omkreds for 10 tommer",
(Select ([profilhøjde]*2+@diameter11)*PI()) AS "omkreds for 11 tommer",
(Select ([profilhøjde]*2+@diameter12)*PI()) AS "omkreds for 12 tommer"
)a
答案 0 :(得分:1)
使用CTE
;with a as
(
select ([brede]*[Profil])/100 as "profilhøjde"
from [Tabel].[dæk]
)
select ("profilhøjde" *2 + @diameter10)*PI() as "diameter 10 tommer"
,("profilhøjde" *2 + @diameter10)*PI() as "diameter 10 tommer"
, ("profilhøjde" *2 + @diameter11)*PI() as "diameter 11 tommer"
, ("profilhøjde" *2 + @diameter10)*PI() as "diameter 12 tommer"
from a
答案 1 :(得分:1)
declare @diameter10 int
select ("profilhøjde" *2 + @diameter10)*PI() as "diameter 10 tommer"
,("profilhøjde" *2 + @diameter10)*PI() as "diameter 10 tommer"
, ("profilhøjde" *2 + @diameter11)*PI() as "diameter 11 tommer"
, ("profilhøjde" *2 + @diameter10)*PI() as "diameter 12 tommer"
from
(select ([brede]*[Profil])/100 as "profilhøjde"
from [Tabel].[dæk]
)a