title: Select max,min, last value from a column in mysql table
body: <p>table format</p>
  
  <pre><code>id   time_stamp
  3    2013-09-05 12:00:00
  5    2013-09-06 12:00:00 
  12   2013-09-07 12:00:00
  2    2013-09-08 12:00:00
  5    2013-09-09 12:00:00
  8    2013-09-10 12:00:00
  </code></pre>
  
  <p>From the above table i want select min(id), max(id), last id, last time_stamp in <strong>single mysql select query statement</strong></p>
  
  <p>Needed output is:</p>
  
  <pre><code>min   max  last(val)  last(time_stamp)
  2     12   8          2013-09-09 12:00:00
  </code></pre>
  
  <p>i used following Query</p>
  
  <pre><code>select id, min(id),max(id), time_stamp from table order by time_stamp limit 1
  </code></pre>
  
  <p><em><strong>I am getting wrong latest id value 3 instead of 8</em></strong></p>
  
  <p>Check this if below SQL fiddle<br>
  <a href="http://www.sqlfiddle.com/#!2/e9cb1/2/0" rel="nofollow">http://www.sqlfiddle.com/#!2/e9cb1/2/0</a></p>