title: How to write an executable postgreSQL to calculate the average and percentage using this schema?
body: <p>I am learning SQL (self taught). I am trying to write an executable postgres SQL query to answer this question: Based on origin city (name), calculate the percentage of trips where the payment
  was at least 10% greater than the average for trips originating in that city.</p>
  
  <p>Context: 1) A completed trip is defined as one with status ‘completed’ in the rentals table. 2) Only considering trips in the last 30 days.</p>
  
  <p>What I started with (hoping this looks good):</p>
  
  <pre><code>SELECT n.name, r.origin_id, SUM(r.fare_dollars), AVG(r.fare_dollars), count(r.id)
  FROM rentals r, neighborhood n
  LEFT JOIN r ON r.origin_id = n.id
  GROUP BY n.name;
  </code></pre>
  
  <p>On the right track?!</p>
  
  <p>What I need your help with (if I am correct about this approach):</p>
  
  <p>The question will require that I do a subquery that will pull all of the records to see how it compares to the average fare. Then I will need to write another query that will tell me which of those rides were 10% higher than the average fare.</p>
  
  <p>I look forward to seeing any insights you may be able to provide! Do let me know if I can provide any additional information.</p>
  
  <p>Thanks.</p>