_spaz Posted April 1, 2010 Share Posted April 1, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/197195-daily-averages-per-month/ Share on other sites More sharing options...
JustLikeIcarus Posted April 1, 2010 Share Posted April 1, 2010 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`) Quote Link to comment https://forums.phpfreaks.com/topic/197195-daily-averages-per-month/#findComment-1035302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.