title: Select New Date from One Table into Another Table with Group By
body: <p>I have 2 Tables:</p>
  
  <p>orders</p>
  
  <ul>
  <li>purchase_date (this is type 'datetime')</li>
  <li>item_price</li>
  <li>sku</li>
  <li>misc other data</li>
  </ul>
  
  <p>total_sales_by_date</p>
  
  <ul>
  <li>date</li>
  <li>total_sales</li>
  </ul>
  
  <p>The orders table is getting updated on a daily basis by an API. The total_sales_by_date table is only adding up ALL the sales across every sku, and grouping them by date with a SUM total for all skus/sales on that date. I'm using this query:</p>
  
  <pre><code>INSERT INTO total_sales_by_date SELECT DATE(purchase_date) AS date, SUM(item_price) AS total_sales FROM orders GROUP BY date
  </code></pre>
  
  <p>For database efficiency, I want to update the 2nd table on a daily basis with only the NEW sales data that came into the 1st table by API. ie- I don't want to re-insert the old data I have already in the 2nd table.</p>
  
  <p>Further, I'd like to create a procedure where this runs every day at 4am (or whatever).</p>