title: Query to get Max/Min row details for multiple fields
body: <p>I have a table structure similar to the following example:</p>
  
  <pre><code>DateTime              V1    V2    V3    V4    
  10/10/10 12:10:00     71    24    33    40
  10/10/10 12:00:00     75    22    44    12
  10/10/10 12:30:00     44    21    44    33
  10/10/10 12:20:00     80    11    88    12
  </code></pre>
  
  <p>With DateTime field being the unqiue and key field, I want a query to output min and max date time for each values so that it will show something like below: <br>
  <br></p>
  
  <pre><code>TYPE    MIN     MINDATETIME         MAX     MAXDATETIME 
  V1      44      10/10/10 12:30:00   80      10/10/10 12:20:00 
  V2      11      10/10/10 12:20:00   24      10/10/10 12:10:00 
  V3      33      10/10/10 12:10:00   88      10/10/10 12:20:00 
  V4      12      10/10/10 12:20:00   40      10/10/10 12:10:00 
  </code></pre>
  
  <p>If there are multiple rows with the same min/max value, then it should get the latest one.<br></p>
  
  <p>With Inner Join on a field, I know to get the details of min/max row for a field, but only way I can think getting everything in one query is to union them all. I think there might be a better solution. Any help is appreciated.</p>
  
  <p>I am using SQL Server 2008.</p>
  
  <p>Thanks.</p>