Averaging Grouped Data
I have a related problem. I am running this select:
SELECT max(datename(mm, dateenquiry)) As [Month],
datepart(yyyy, Dateenquiry) AS [Year],
count(name) as [Frequency],
sum(ValueofClaim) as [Total Value],
sum(Expences) as [Monthly Expense]
From JC_Entities
GROUP BY DATEPART(yyyy, Dateenquiry),
DATEPART(m, dateenquiry)
ORDER BY DATEPART(yyyy, Dateenquiry),
DATEPART(m, dateenquiry)
which works to give me the number of items and the totals of columns, but I now want to arrive at an AVG for each row and to perform a calculation say [Monthly Expense] / [Frequency].
I have failed to get this any further and I wanted to run it from an .aspx file as a stored procedure.
Any help would be appreciated.
Andy Hodges
Andy Hodges
|