I have a SQL variable @SumScore dec(9,4)
I am trying to assign a variable as follows:
SET @SumScore =
(
SELECT Sum(
(
SELECT SUM(etjs.CalculatedScore * sc.PercentOfTotal) as CategoryScore
FROM tblEventTurnJudgeScores etjs
INNER JOIN tblJudgingCriteria jc ON jc.JudgingCriteriaID = etjs.JudgingCriteriaID
INNER JOIN tblScoringCategories sc ON jc.ScoringCategoryID = sc.ScoringCategoryID
GROUP BY jc.JudgingCriteriaID
)
As ComputedScore) AS SumTotalScore
)
In other words, internal selection returns a single column. I want var to be assigned the SUM of all the rows that are returned there.
I understand that this can be done using the temp table quite easily. But is this the only way?
source
share