TSQL Inner Select with SUM
|September 15, 2014||Posted by forumadmin under TechQns||
I am trying to get the sum of 2 values in my inner select but get an error about the aggregate function.
I am just trying to understand how I need to format this differently to get it working.
Is there a different order I need to do this in?
(SELECT CONVERT(VARCHAR,D.[booksCost],1) AS booksCost, CONVERT(VARCHAR,D.[tuitionCost],1) AS tuitionCost, SUM (D.[booksCost] + D.[tuitionCost]) AS totalCost, D.[className] FROM tuitionApplicationClasses AS D WHERE applicationID = A.[applicationID] FOR XML PATH ('classData'), TYPE, ELEMENTS), Column 'tuitionApplicationClasses.booksCost' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
|Asked By – SBB||Read Answers|