0

我尝试使用 SQL Server 2008 进行计算列,但在附近出现语法错误>

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

谁能告诉我有什么问题?

4

1 回答 1

2

数量必须在 then 之后

Select *, AverageCost = 
case when Quantity > 0 then (TotalCost / Quantity) else null end from ProductTable;
于 2013-02-03T21:57:26.690 回答