SQL SUM案例声明

时间:2017-01-26 19:17:08

标签: sql

我有:

SUM
(
case
when LC.[DWC] = 0 and LC.BI = 1 then 1
else LC.[DWC] END AS DC
) 
AS [DWC]

但我收到一条错误消息:

  

' SUM'不是公认的内置函数名称。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

假设您使用的是sql-server:

Select SUM(CASE WHEN (LC.[DWC] = 0 and LC.BI = 1) THEN 1 ELSE LC.[DWC] END) AS [DWC] 
FROM LC