Jump to content

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`)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.