我需要在SQL Server中编写一个查询,该查询获取每个组的某个列的最大值以及另一列的对应值。
这是我的情况的简化
group | value | other_value
-------+-------+------------
First | 5 | 2
First | 12 | 4
First | 7 | 7
Second | 12 | 43
Second | 45 | 12
Third | 45 | 7
查询结果:
group | max_value | other_value
-------+-----------+------------
First | 12 | 4
Second | 45 | 12
Third | 45 | 7