Completed question 8.  Hope I wasn't supposed to use joins.
created test code to see how average function works.
completed question 9