表格:
ID A B C D E
----------------------------------------------
1 4 370692690 917400014333 307 990
2 4 370692690 917400014333 392 767
3 2 370692690 917400014333 337 367
4 3 370692690 917400014333 269 284
如果行具有匹配的A,B和C列(在本例中为第1行和第2行),则选择MAX(D)行。
结果:
ID A B C D E
----------------------------------------------
2 4 370692690 917400014333 392 767
3 2 370692690 917400014333 337 367
4 3 370692690 917400014333 269 284
答案 0 :(得分:0)
以下是3列和最高ID的示例:
select *
from (
select row_number() over (partition by A, B, C order by ID desc) as rn
, *
from Table1
) sub
where rn = 1 -- Only highest ID per A, B, C group