title: SQL AVERAGE TIME
body: <p>I have the following query in MSSQL:</p>
  
  <pre><code>select 
  TRANSACTION_TYPE_ID
  ,COUNT(TRANSACTION_TYPE_ID)AS NUMBER_OF_TRANSACTIONS
  ,CAST(SUM(AMOUNT)AS DECIMAL (30,2)) AS TOTAL
  FROM 
      [ONLINE_TRANSACTION] 
  WHERE CONVERT(CHAR(8), CREATED_ON, 114) &gt;='17:30' AND AMOUNT IS NOT NULL AND     
  TRANSACTION_TYPE_ID !='CHEQUE-STOP-TRANS-TYPE' 
  GROUP BY TRANSACTION_TYPE_ID
  ORDER BY TRANSACTION_TYPE_ID
  </code></pre>
  
  <p>I want to show the type of transactions <code>TRANSATION_TYPE_ID</code> as above the total amount of each type of transaction as above BUT also the average time these transactions occurred <code>CREATED_ON</code> which is <code>datetime</code> I still have not find a good way of doing this?</p>