title: max_by function equivalent in SQL Server
body: <p>I have to translate a query provided to me into SQL Server query. It uses <code>max_by</code> function which essentially does this.</p>
  <blockquote>
  <p>MAX_BY takes two arguments and returns the value of the first argument for which the value of the second argument is maximized. If multiple rows maximize the result of the second value, and arbitrary first value is chosen from among them. MAX_BY can be used with both numeric and non-numeric data.</p>
  </blockquote>
  <p><a href="https://docs.data.world/documentation/sql/reference/aggregations/max_by.html" rel="nofollow noreferrer">https://docs.data.world/documentation/sql/reference/aggregations/max_by.html</a></p>
  <p>A quick sample problem query that needs to be translated</p>
  <pre><code>SELECT 
      max_by(score, dob)
  FROM
      table_1 t1
      INNER JOIN table_2 t2 ON t1.id = t2.id
  </code></pre>
  <p>I cannot do this processing in the code and need to do this in the query. Kindly suggest if there is a equivalent function in SQL Server that I can use directly or the simplest work around if a function is not available</p>