Morpheus7
asked on
Averaging yearly data
Hi,
I have a table that contains monthly averages as follows:
Date(Datetime) fat_percent(Float), oil_percent(Float), MSG_Percent(Float), Quantity(INT).
For each year there are 12 entries. I would like to be able to calculate an average for each year.
The table hold 15 years of data, so I would like to return a row for each year with the with the values for each column.
Any help would be appreciated.
Thanks
I have a table that contains monthly averages as follows:
Date(Datetime) fat_percent(Float), oil_percent(Float), MSG_Percent(Float), Quantity(INT).
For each year there are 12 entries. I would like to be able to calculate an average for each year.
The table hold 15 years of data, so I would like to return a row for each year with the with the values for each column.
Any help would be appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
something like this?
select YEAR(Date), SUM(fat_percent), SUM(oil_percent), sum(MSG_Percent), sum(Quantity)
from your tablename
group by YEAR(Date)
Order by 1
select YEAR(Date), SUM(fat_percent), SUM(oil_percent), sum(MSG_Percent), sum(Quantity)
from your tablename
group by YEAR(Date)
Order by 1
a minute too late!
And it should be Avg, not Sum
Some rows with actual data and the expected result.