Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Use SUM function inside Update Statement Expand / Collapse
Posted Wednesday, October 24, 2012 8:59 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
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'
Post #1376757
Posted Thursday, October 25, 2012 1:51 AM



Group: General Forum Members
Last Login: Wednesday, August 24, 2016 1:36 AM
Points: 15,289, Visits: 13,074
For starters you'll need to include a GROUP BY on every column in the SELECT list that is not aggregated.

How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1376827
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse