###### Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
###### Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
###### Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

# calculating a weighted average in SQL, SSRS

asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SSRS
7 Comments1 Solution8331 ViewsLast Modified:
Hello Experts,

Does anyone know how to calculate a weighted average in SQL?

First I get the average of something: COUNT(transactions)/Fee = Average
Then to get the weighted average I would have to total the above values of 'Average' for the three different transactions types we use, and then divide that by the total count.

I cannot create a calculated field because in SSRS you can't use aggregate functions in a calc field. Also, in SSRS, I have tried creating an expression:

=(SUM((Fields!CRDTAMNT.Value/COUNT(Fields!Trans.Value))* COUNT(Fields!Trans.Value)))/COUNT(Fields!Trans.Value)

and I keep getting errors about nested aggregate functions.

So first of all, should I do this in my query or somewhere in SSRS?
Second of all, what is the code/syntax to achieve this?

Thanks.

ASKER CERTIFIED SOLUTION
ralmada
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers