title: How can I average number of items in our SQLite database by 24-hour period?
body: <p>Trying to create a report for our support ticketing system and I'm trying to have 2 results in the report that show a rolling average of how many tickets were opened in a day and how many were closed in a day.</p>
  
  <p>Basically, query the entire tickets table, separate out everything by individual days that the tickets were created on, count the number tickets for each individual day, then average that number.</p>
  
  <p>My friend gave me this query: </p>
  
  <pre><code>SELECT AVG(ticket_count)
  FROM (SELECT COUNT(*) AS ticket_count FROM tickets
  GROUP BY DATE(created_at, '%Y'), DATE(created_at, '%m'), DATE(created_at, '%d')) AS ticket_part
  </code></pre>
  
  <p>But it's not seeming to work for me. All I get is a single result with the number of tickets created last year.</p>