title: How to select top N rows with the sum of certain column meet some requirement in SQLite?
body: <p>If we have one table with a column called X contains int. Now I want to select (Actually I want to delete) the oldest N rows with the sum of X as much as possible but no more than 300?</p>
  
  <pre><code>  _id|X
      1|50
      2|150
      3|80
      4|100
      5|200
      6|70
  </code></pre>
  
  <p>Where 1 is oldest, 6 is newest. So I want to get row 1, 2, 3, whose sum of X is 280. Is it possible to achieve this with one single select statement?</p>