2013-02-03 51 views
0

我嘗試使用SQL Server 2008做一個計算列,但要接近>語法錯誤:如何糾正T-SQL語法錯誤?

Select 
    *, 
    AverageCost = case Quantity 
        when > 0 then (TotalCost/Quantity) 
        else null 
       end 
from ProductTable; 

可能有人用銳利的眼睛告訴我,什麼是錯的?

回答

2

的數量必須再經過

Select *, AverageCost = 
case when Quantity > 0 then (TotalCost/Quantity) else null end from ProductTable; 
+0

太感謝你了!當時間鎖定允許時將接受答案。 – user776676