Reputation: 9416
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;
The CASE WHEN in the above statement is giving trouble with the error below. Any one know what i'm missing?
Common table expression defined but not used..
Upvotes: 0
Views: 5061
Reputation: 5398
Try this
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;
Upvotes: 0
Reputation: 5782
Common table expression defined but not used..
this is mean that you create CTE but do not use it, same error as in snapshot below
Upvotes: 1
Reputation: 1391
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;
Its a parenthesis problem.
Upvotes: 0