title: T-SQL: Selecting Column Based on MAX(Other Column)
body: <p>I'm hoping there's a simple way to do this without using a sub-query:</p>
  
  <p>Scenario:  You have "TableA" with columns "Key", "SubKey", and "Value".  I need to get the "Value" of the MAX("SubKey") for a given "Key".</p>
  
  <p>So if the Table contained the rows:</p>
  
  <pre><code>KEY SUBKEY VALUE
  1   1      100
  1   2      200
  1   3      300
  </code></pre>
  
  <p>For Key = 1, I need the value 300.  I was hoping to do something like this:</p>
  
  <pre><code>SELECT
    VALUE
  FROM
    TableA
  WHERE
    Key = 1
  HAVING
    SubKey = MAX(SubKey)
  </code></pre>
  
  <p>But that's a no-go.  Is there a way to do this without doing a 'WHERE SubKey = (subselect for max subkey)'?</p>