title: sql average of a sum divided by a count
body: <p>I am trying to do an SQL query to get the average spend for a specific customer.</p>
  
  <p>I have written the following SQL (this is slighlty cut down for this example)..</p>
  
  <pre><code>SELECT SUM(price) as sumPrice, COUNT(transactionId) as transactionCount, customerName
  FROM customers, transactions
  WHERE customers.customerId = transactions.customerId
  AND transactiontypeId = 1
  GROUP BY customers.customerId
  </code></pre>
  
  <p>This gives me the sum of the transaction and the count. With this I can then divide the sum by the count to get the average spend. However I would like to be able to get the Average as a value straight out of the database rather than manipulate the data once I have got it out.</p>
  
  <p>Is there any way to do this? I have played around with writing a select within a select but haven;t had much luck as of yet, hence asking on here.</p>
  
  <p>Thanks in advance</p>