title: Query to select SUM of a single column based on date
body: <p>Hello guys i've been having a problem getting the query for MySQL to select 2 sums.</p>
  
  <p>I have a table like this</p>
  
  <pre><code>--------------------------------------
  | im_id | cat |_id | qty | date_added |
  --------------------------------------
  </code></pre>
  
  <p>i need to get the 2 sums of the quantity based on the date added, and grouping them by cat_id</p>
  
  <p>how can i achieve this?</p>
  
  <p>heres my query</p>
  
  <pre><code>select sum(qty), SUM(CASE WHEN date_added &lt; CURDATE() THEN qty ELSE 0 END) 
  from inventory_movement 
  where dated_added &lt;= CURDATE() 
  GROUP BY cat_id
  </code></pre>
  
  <p>i am trying to get the ending inventory and beginning inventory based on the movement on this table?
  can anyone help me?</p>