Re: Help with AVG()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have continued to work on the average query I need help.  I am still needing help.

What I donât understand is why 

`bible_anagrams_rss_feed`.`rss_feed_date` BETWEEN `bible_anagrams_rss_feed`.`rss_feed_date` AND DATE_SUB( `bible_anagrams_rss_feed`.`rss_feed_date` , INTERVAL -1 WEEK )

wonât isnât selecting the 7 consecutive dates leading up to and including the date of `bible_anagrams_rss_feed`.`rss_feed_date`  I am only getting the value of `bible_anagrams`.`views` from the current date as the value of average_views in the query:


SELECT 

`bible_anagrams_rss_feed`.`rss_feed_date` , SUM( `bible_anagrams`.`views` ) AS total_views , SUM( `bible_anagrams`.`views` ) / COUNT(`bible_anagrams_rss_feed`.`reference`) AS average_views

FROM `bible_anagrams_rss_feed` INNER JOIN `bible_anagrams` ON `bible_anagrams_rss_feed`.`bible_anagrams_reference` = `bible_anagrams`.`reference`

WHERE 

`bible_anagrams_rss_feed`.`rss_feed_date` BETWEEN `bible_anagrams_rss_feed`.`rss_feed_date` AND DATE_SUB( `bible_anagrams_rss_feed`.`rss_feed_date` , INTERVAL -1 WEEK )

GROUP BY `bible_anagrams_rss_feed`.`rss_feed_date`

ORDER BY `bible_anagrams_rss_feed`.`rss_feed_date` DESC
rss_feed_date Descending     total_views     average_views
2011-06-13 12:00:02     13     13.0000
2011-06-12 12:00:01     10     10.0000
2011-06-11 12:00:02     18     18.0000
2011-06-10 12:00:02     14     14.0000
2011-06-09 12:00:01     20     20.0000
2011-06-08 12:00:01     28     28.0000
2011-06-07 12:00:03     15     15.0000
2011-06-06 12:00:02     21     21.0000
2011-06-05 12:00:01     20     20.0000
2011-06-04 12:00:02     33     33.0000
2011-06-03 12:00:02     23     23.0000
2011-06-02 12:00:02     25     25.0000
2011-06-01 12:00:01     13     13.0000
2011-05-31 12:00:02     41     41.0000
2011-05-30 12:00:01     27     27.0000
Ron
The Verse of the Day
âEncouragement from Godâs Wordâ
http://www.TheVerseOfTheDay.info  

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux