title: One to many join, Sum from both table
body: <p>I have two table orders and ordersdetail having millions of rows..</p>
  
  <p>Tables:</p>
  
  <p><strong>orders</strong>- id(primary key), amount, date( index)</p>
  
  <p><strong>orderdeails</strong>- id(primary key), skunitid, quantity, order_id(index)</p>
  
  <p>One order have multiple order detail...</p>
  
  <p>Query: </p>
  
  <pre><code>Select Sum(orders.amount),SUM(ordersdetails.quantity)
  from orders join orderdetails on ordersdetail.order_id = orders.id 
  where {{conditios on date column of order table}}
  </code></pre>
  
  <p>I knw its wrong query, I want data sum of amount and sum of quantity in single query(single iteration) but when I use join order's table amount comes so many time. I have index on date column in order table, so i must have to start query from order table (million rows in table.)</p>
  
  <p>I must need efficient way..</p>