views:

61

answers:

2

I am trying to determine a SCORE from 11 rows in a table.

Those 11 rows are being aggregated into five rows using a ScoringCategoryID column as follows...

ScoringCategoryID   CategoryScore       PercentOfTotal
---------------------------------------------------------
7                   15.00             0.40  
8                   15.00             0.30  
9                   14.50             0.20  
10                  4.50             0.05  
11                  4.50             0.05

I need to get a RawScore from this data. Unfortunately my customer does not want me to merely sum the CategoryScore column (53.5 total). Do you see how the PercentOfTotal column sums to 1. Each ScoringCategoryID therefore has a WEIGHT. So of the total score...ScoringCategoryID is supposed to be 40% of the score. ScorCatID 8 is supposed to be 30% of the total etc.

I am not sure how to do this in a query. How do I get the Score?

Here is the current query...

SELECT jc.ScoringCategoryID, 
       SUM(etjs.CalculatedScore) as CategoryScore,  
       Max(sc.PercentOfTotal) PercentOfTotalScore  
  FROM tblEventTurnJudgeScores etjs  
INNER JOIN tblJudgingCriteria jc ON  jc.JudgingCriteriaID = etjs.JudgingCriteriaID  
INNER JOIN tblScoringCategories sc ON jc.ScoringCategoryID = sc.ScoringCategoryID  
WHERE etjs.EventTurnJudgeID = 1068  
GROUP BY jc.ScoringCategoryID

This is supposed to be aggregated into a single score. Any ideas.

+1  A: 
SELECT SUM(CategoryScore * PercentOfTotal) as RawScore
  FROM ( .....subquery here..... )
Amber
Short of rounding, won't that give you the same as just `SELECT SUM(CategoryScore)`?
OMG Ponies
Um, no? Since the weights are not equal to 1, but rather sum to 1, the sum of scores*weights is not the same as sum(scores). (4 * 0.3) + (5 * 0.7) = 1.2+3.5 = 4.7 is not the same as (4+5) = 9, nor is it the same as (4+5)*(0.3+0.7) = 9.
Amber
Dav,What you have is exactly how I did it to start off. However, the score has to scale to a MAX POTENTIAL. That is where I am lacking information. If you just multiply by the PercentOfTotal then total score is reduced. because each line is multiplied by %. For the purposes of this algorithm that will not work.Seth
Seth Spearman
You never mentioned a max potential in your post, thus it would have been rather difficult to take such into account. What exactly do you mean by 'max potential'? An example would be handy here.
Amber
A: 

I think we need more information to help you. What is the maximum value that any Category Score can be or does that change per the category?

RandomBen