title: T-SQL: SELECT related column data for the max two other columns
body: <p>I have table data like the following, where order type is 1 for a quote, and 2 for an order.  Any given po_num can have 0 to many of order_type 1, but should only have only 0 or 1 of order_type 2, or all of the above.</p>
  
  <p>I need to return the max order_num of the max order_type of a given po_num, where the order_num is just an additional (but important) column in my result.</p>
  
  <p>Table data:</p>
  
  <pre><code>order_type  po_num  order_num
  1           E0102   1013200
  1           E0102   1013162
  1           E0104   1012161 
  2           E0104   1012150
  1           E0104   1011449
  2           E0107   1010034
  2           E0108   1011994
  </code></pre>
  
  <p>Desired result:</p>
  
  <pre><code>order_type  po_num  order_num
  1           E0102   1013200
  2           E0104   1012950
  2           E0107   1010034
  2           E0108   1011994
  </code></pre>
  
  <p>The closest I can get is this, which still includes the max(order_no) for both order_type of 1, and order_no of order type 2:</p>
  
  <pre><code>order_type  po_num  order_num
  1           E0102   1013162
  1           E0104   1012161
  2           E0104   1012150
  2           E0107   1010034
  2           E0108   1011994
  </code></pre>