title: Using average in query (PostgreSQL)
body: <p>I'm having trouble with coming up with a query to find the average age of the buses used for each bus company from the following schema:</p>
  
  <p>buscompany</p>
  
  <pre><code>company_id | name
   1           NED
   2           JIM
  </code></pre>
  
  <p>bustype</p>
  
  <pre><code>type_id | date_made
   1        2006-01-26
   2        1999-05-05
   3        2000-09-01
  </code></pre>
  
  <p>route</p>
  
  <pre><code>route_id | bustype | bus_company
   1         2         1
   2         1         1
   3         1         1
   4         3         2
   5         3         2
   6         1         2
   7         2         2
  </code></pre>
  
  <p>In this example NED's average bus age is 4246.666 = 4247 days assuming today is 2013-03-18.</p>
  
  <p>What would the whole query look like?</p>