Help with AVG()

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

 



Hi Everyone

I am trying to figure out how to write a SELECT query that will give me the average of `bible_anagrams`.`views` starting on the date specified in `bible_anagrams_rss_feed`.`rss_feed_date` and the previous 6 calendar days (for a total of 7 days).  What I am trying to figure out is the average of how many times the anagrams RSS Feed were accessed between June 1st and 7th, June 2nd and 8th, June 3rd and 9th, etc.

- There is 1 row for each date in the table bible_anagrams_rss_feed.
I tried the following syntax, but it is giving me an overall average, not by the date ranges:



SELECT AVG(`bible_anagrams`.`views`) AS average_views FROM `bible_anagrams` INNER JOIN `bible_anagrams_rss_feed` ON `bible_anagrams`.`reference` = `bible_anagrams_rss_feed`.`bible_anagrams_reference` ORDER BY `bible_anagrams_rss_feed`.`rss_feed_date` DESC LIMIT 7




I am wanting the query I am asking help for to be included as one of the mySQL results, where I have indicated âAVERAGE VIEWS QUERY HEREâ (although if there is a better way I am opening to learning it):



SELECT `bible_anagrams_rss_feed`.`rss_feed_date` , `bible_anagrams`.`reference`, `bible_anagrams`.`bible_anagram_word` , `bible_anagrams`.`views` , 

(

AVERAGE VIEWS QUERY HERE

) AS average_views

FROM `bible_anagrams_rss_feed` INNER JOIN `bible_anagrams` ON `bible_anagrams`.`reference` = `bible_anagrams_rss_feed`.`bible_anagrams_reference` 
ORDER BY `bible_anagrams_rss_feed`.`rss_feed_date` DESC



Thanks for helping me,

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