0

I am trying to populate a column (2003_revenue) with the sum of two columns, STB and Addon that exist in the temp table #CombinedRevTable_2003. However, if both STB and Addon are null, I want to populate the column with Null.

I keep getting an error with my code that there is incorrect syntax near the keyword 'from'.

UPDATE data.revenuesummary
SET 2003_Revenue = (
    SELECT CASE 
      WHEN (STB IS NULL AND Addon IS NULL) THEN NULL 
      ELSE SUM(ISNULL(STB,0)) + SUM(ISNULL(Addon,0)) 
    FROM #CombinedRevTable_2003 b
    WHERE b.ID = data.revenuesummary.ID
)

Any assistance would be greatly appreciated.

Thanks!

1 Answer 1

1

You're missing an END for the CASE statement

UPDATE data.revenuesummary
SET 2003_Revenue = (
    SELECT CASE 
      WHEN (STB IS NULL AND Addon IS NULL) THEN NULL 
      ELSE SUM(ISNULL(STB,0)) + SUM(ISNULL(Addon,0))
    END
    FROM #CombinedRevTable_2003 b
    WHERE b.ID = data.revenuesummary.ID
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.