Use SUM function inside Update Statement

  • How do we use SUM in side update statement. Please review the below query and help me

    select [September 2012 Billing File] = CASE WHEN T2.[Application ID] IS NOT NULL AND T2.[ServerName]

    IS NOT NULL AND Sum([Billed This Month]) <> 0 THEN 'Y' ELSE 'N' END

    FROM [AEG_DB].[dbo].[TBL_Work] T1

    LEFT JOIN [TBL_Data] T2 ON (T1.[Application ID] = T2.[Application ID] AND T1.[ServerName] = T2.[ServerName])

    WHERE T2.[Data Period] = 'September 2012'

  • For starters you'll need to include a GROUP BY on every column in the SELECT list that is not aggregated.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply