title: logic for handling tie with aggregate
body: <p>I have this data set: </p>
  
  <pre><code>|  ID | TYPE | PERCENT |
  ------|------|---------|
  | 123 |    A |     0.5 |
  | 123 |    B |     0.5 |
  | 456 |    A |     0.7 |
  | 456 |    B |     0.3 |
  | 789 |    A |       1 |
  </code></pre>
  
  <p>I would like the following result:</p>
  
  <pre><code>|  ID | TYPE | PERCENT |
  ------|------|---------|
  | 123 |    A |     0.5 |
  | 456 |    A |     0.7 |
  | 789 |    A |       1 |
  </code></pre>
  
  <p>That is, getting the <code>MAX(percent)</code> for each <code>id</code> and the corresponding <code>type</code>.</p>
  
  <p>I'm currently using</p>
  
  <pre><code>SELECT ... 
  FROM
    (SELECT [id], MAX([percent]) AS [p]
    FROM [highest]
    GROUP BY [id]) a
  LEFT JOIN [highest] b 
    ON b.[id] = a.[id]
      AND b.[percent] = a.[p]
  </code></pre>
  
  <p>And getting </p>
  
  <pre><code>|  ID |   P | TYPE | PERCENT |
  --- --|-----|------|---------|
  | 123 | 0.5 |    A |     0.5 |
  | 123 | 0.5 |    B |     0.5 |
  | 456 | 0.7 |    A |     0.7 |
  | 789 |   1 |    A |       1 |
  </code></pre>