title: Aggregate functions in WHERE clause in SQLite
body: <p>Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this:</p>
  
  <pre><code>SELECT * FROM table ORDER BY timestamp DESC LIMIT 1
  </code></pre>
  
  <p>But I'd much rather do something like this:</p>
  
  <pre><code>SELECT * FROM table WHERE timestamp=max(timestamp)
  </code></pre>
  
  <p>However, SQLite rejects this query:</p>
  
  <pre><code>SQL error: misuse of aggregate function max()
  </code></pre>
  
  <p>The <a href="http://www.sqlite.org/lang_expr.html" rel="noreferrer">documentation</a> confirms this behavior (bottom of page):</p>
  
  <blockquote>
    <p>Aggregate functions may only be used in a SELECT statement.</p>
  </blockquote>
  
  <p>My question is: is it possible to write a query to get the row with the greatest timestamp without ordering the select and limiting the number of returned rows to 1? This seems like it should be possible, but I guess my SQL-fu isn't up to snuff.</p>