I have to translate a query provided to me into SQL Server query. It uses max_by
function which essentially does this.
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.
https://docs.data.world/documentation/sql/reference/aggregations/max_by.html
A quick sample problem query that needs to be translated
SELECT
max_by(score, dob)
FROM
table_1 t1
INNER JOIN table_2 t2 ON t1.id = t2.id
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