2016-11-09 24 views
0

如何讓sql計算並將結果傳遞給臨時列,然後將該結果用另一個計算結果與另一個tabel中的值進行比較,然後將結果傳遞給一個臨時列sql計算將結果保存在temp列中並將其傳遞給另一個計算

我越來越

無效列名 '英寸'。

SELECT 10 AS inch 
SELECT inch *25.4 AS diameter 
SELECT P.[merged], 
(P.[profile]*2+diameter)*PI() AS circumference 
FROM [dbo].[profilelist] P; 

我可以得到它與這個

SELECT 10 AS inch 
select 10*25.4 as diameter 
SELECT P.[merged], 
(P.[profile] *2+254)*PI() as circumference 

    FROM [dbo].[profilelist] P; 

回答

1

工作,看看這是你在找什麼。

Declare @inch int, @diameter decimal(5,2) 
SELECT @inch=10 
SELECT @diameter = @inch * 25.4 
SELECT P.[merged], 
(P.[profile]*[email protected])*PI() AS circumference 
FROM [dbo].[profilelist] P; 
+0

這將工作,但無論如何這樣做,所以你可以看到多個結果?如直徑和圓周的結果 –

+1

選擇變量。 IE瀏覽器。 'Select @inch,@ diameter,etc.' –

+0

有沒有辦法通過'SELECT P. [merged],@cross = P。[profile] * 2 + @ diameter)* PI()AS peripheral' to another因爲它只顯示1列 –

相關問題