找到了,预计';'错误

时间:2013-12-18 12:46:25

标签: sql-server-2008

我在下面的sql CASE语句中收到错误。它在(CASE WHEN SUM(ISNULL(OQ.Quantity,0) = 0 THEN SUM(R.Quantity) - SUM(R.Quantity * .9275))上爆炸。有人可以帮忙吗?感谢

CASE
    WHEN SUM(ISNULL(OQ.Quantity,0)) = 0 THEN SUM(R.Quantity * .9275)
    ELSE SUM(OQ.Quantity)
  END AS On_Time_Quantity,  

CASE
    WHEN SUM(ISNULL(OQ.Quantity,0)) > SUM(R.Quantity) THEN 0
    ELSE 
      **CASE WHEN SUM(ISNULL(OQ.Quantity,0) = 0 THEN SUM(R.Quantity) - SUM(R.Quantity * .9275))**
    ELSE 
      CASE WHEN SUM(ISNULL(OQ.Quantity,0) < SUM(R.Quantity) THEN SUM(R.Quantity) - SUM(ISNULL(OQ.Quantity,0))
  END
  END AS Late_Quantity,

1 个答案:

答案 0 :(得分:0)

在新行上有THEN或在THEN之前使用冒号终止表达式:

CASE
  WHEN ... ; THEN

OR

CASE
  WHEN ...
  THEN