Jump to content

Daily Averages per Month


_spaz

Recommended Posts

How does one get the daily averages per month from a bunch of data with titles and Durations on different dates?

 

Example:

date              Title      Duration

2010-02-01      1          10

2010-02-03      2          16

2010-02-01      3            24

2010-03-02      4          10

2010-03-08      5          10

etc...

 

 

I have this so far but its not calculating the daily average by Month properly

 

Select Month(`date`) as Month,

avg(`duration`) AS 'Daily Duration'

from Table

where `date` between '2009-01-01' and '2009-12-31'

group by Month

Link to comment
https://forums.phpfreaks.com/topic/197195-daily-averages-per-month/
Share on other sites

Try one of these.  I think you want the second one

For Monthly Averages

Select Month(`date`),  avg(`duration`) AS 'Daily Duration'
from Table
where `date` between '2009-01-01' and '2009-12-31'
group by Month(`date`)

 

For Daily averages

Select Month(`date`), Day(`date`), avg(`duration`) AS 'Daily Duration'
from Table
where `date` between '2009-01-01' and '2009-12-31'
group by Month(`date`), Day(`date`)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.