i have this in my query. select sentence,Comma,age from x innnerjoin y...if my sentence= 365 Name =Comma, age =34
Sentence
Name
age
365
Comma
34
so i want to take the average of sentence. suppose i enter the same Name and age together for 2-3 time.so my average should add my previous value plus my current value. unless the age changes.than it display a new value.i have a code in my ssrs dataset which
runs fine and display to total value but i got stuck in my query and expression.im not sure
how to loop or add my previous to the current value.in my expression i have
=avg(fields!sentence.value)
still give me the total value but not the average value.is any other way in expression to calculate the averge value
vadz
Member
6 Points
22 Posts
average in sql server reporting system 2008
Nov 13, 2012 08:57 PM|LINK
i have this in my query. select sentence,Comma,age from x innnerjoin y...if my sentence= 365 Name =Comma, age =34
so i want to take the average of sentence. suppose i enter the same Name and age together for 2-3 time.so my average should add my previous value plus my current value. unless the age changes.than it display a new value.i have a code in my ssrs dataset which runs fine and display to total value but i got stuck in my query and expression.im not sure
how to loop or add my previous to the current value.in my expression i have
still give me the total value but not the average value.is any other way in expression to calculate the averge value
thanks in advance
.
mezzanine74
Contributor
2480 Points
730 Posts
Re: average in sql server reporting system 2008
Nov 14, 2012 06:22 AM|LINK
You can pull Average Value of ages per User as highlighted below in Red. So you will get a new column as called AverageAge
select
sentence
,Comma
,age
,DataSourceAverage.AverageAge
from x
INNER JOIN
(SELECT Name, AVR(Age) AS AverageAge FROM X GROUP BY Name) AS DataSourceAverage
ON DataSourceAverage.Name = x.Comma
INNER JOIN y ...
vadz
Member
6 Points
22 Posts
Re: average in sql server reporting system 2008
Nov 15, 2012 09:52 PM|LINK
hi
thanks for reply
in new to sql query by my query looks ok..so i want to take the average value from sentence..in your code above
do i have to create another column for datasource.averageAge?...cause i only 3 columns
select distinct s.sentence,c.comma,a.age
from x
innerjoin ...<expression here>
where sentenceDate between @startdate and @enddate = select avg(sentence) as Average from x group by name )
i do this i got an error on,cause sentenceDate has no column
please help