title: mysql count quantity column and return position with row
body: <p>I have a table:</p>
  
  <pre><code>ID int
  category int
  quantity int
  timestamp timestamp
  </code></pre>
  
  <p>I want to SELECT id="id#" and return a 'position' which is the sum of quantity for each row that has an earlier timestamp in the same category.</p>
  
  <p>Thanks for your pointers!</p>