SELECT Country, EmployeeName, Name As [FullName], OutPut1, OutPut2, OutPut3,
(OutPut1 + OutPut2 + OutPut3) AS Total,
CASE WHEN Name IS NULL THEN '.........'
WHEN Name IS NOT NULL THEN '??????'
END)
AS ParentID
FROM CTE_Report;
上述声明中的情况正在解决以下错误。任何人都知道我错过了什么?
已定义公用表表达式但未使用..
答案 0 :(得分:1)
已定义公用表表达式但未使用..
这意味着您创建CTE但不使用它, 与下面的快照相同的错误
答案 1 :(得分:0)
SELECT Country, EmployeeName, Name As [FullName], OutPut1, OutPut2, OutPut3,
(OutPut1 + OutPut2 + OutPut3) AS Total,
CASE WHEN Name IS NULL THEN '.........'
WHEN Name IS NOT NULL THEN '??????'
END
AS ParentID
FROM CTE_Report;
它是一个括号问题。
答案 2 :(得分:0)
试试这个
SELECT Country,
EmployeeName,
Name AS [FullName],
OutPut1,
OutPut2,
OutPut3,
( OutPut1 + OutPut2 + OutPut3 ) AS Total,
CASE
WHEN Name IS NULL THEN '.........'
ELSE '??????'
END AS ParentID
FROM CTE_Report;