title: SQLite: select MIN from limited row set
body: <p>I need to select min ID value from top 5 rows in the table. I get top IDs with this query:</p>
  
  <pre><code>SELECT id FROM items ORDER BY id DESC LIMIT 5
  </code></pre>
  
  <p>It works fine and returns ID values from top 5 rows:</p>
  
  <pre><code>314
  313
  312
  311
  310
  </code></pre>
  
  <p>Now, trying to get the minimal ID from this set:</p>
  
  <pre><code>SELECT MIN(id) FROM items ORDER BY id DESC LIMIT 5
  </code></pre>
  
  <p>I expect the result to be <strong>310</strong> but SQLite return <strong>1</strong>.
  What's up with that? Where am I wrong and do I achieve my goal?</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p><code>SELECT MIN(id) FROM (SELECT id FROM news_items ORDER BY id DESC LIMIT 5)</code> works, so now I'm just curious about what's wrong with the first query.</p>