June 28, 2005 at 4:58 pm
I have a dynamic column group in a matrix. I have read (Lachev) that the only aggragate operation allowed on data in row and column groups is Summing.
Has anyone figured out how to Average data across a row?
Example
name A B C D ave
tom 3 5 7 1 4
bob 2 5 6 11 6
June 28, 2005 at 10:28 pm
Select name, A, B, C, D, (A + B + C + D) / 4.0 as Average from dbo.YourTable
June 29, 2005 at 7:51 am
Well, if I go that route, I'll have to rewrite the slightly complicated SP that generates A,B,C & D. This might be doable. I'll post an update later today.
June 29, 2005 at 7:55 am
Can you provide all the informations then??
If you post the original query then I might be able to provide more info.
June 29, 2005 at 3:19 pm
I am still a little hesitant to post my SP code, not because of secrecy but because of complexity
Perhaps a better example to illustrate my problem is
Desired result:
Student| Assessor | Assessor | Assessor | Assessor |
| A | B | C | D | AVG |
tom | 3 | 5 | 7 | 1 | 4 |
bob | 2 | 5 | 6 | 11 | 6 |
Student| Assessor | Assessor | Assessor | Assessor |
| A | B | C | D |
tom | 3 | 5 | 7 | 1 |
bob | 2 | 5 | 6 | 11 |
This a matrix built on a Stored Procedure that returns:
student name | assessor name | score |
tom | A | 1 |
tom | A | 2 |
tom | B | 2 |
tom | B | 1 |
tom | B | 2 |
etc.......................
June 29, 2005 at 3:23 pm
If you don't want to rerun the query for performance, then you can always create a temp table to old the results.
Insert the results in the temp table.
Select the #temp table with the average this time, drop the temp table at the end of the proc.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply