ROW_NUMBER()OVER(由Mdate DESC订购的分段)由于M b FROM tblTestData),CTE2 AS( SELECT A,B,C,Mdate, ROW_NUMBER()OVER(按B顺序划分Mdate DESC )由于M¥ FROM tblTestData) SELECT A,B,C,Mdate FROM CTE1 WHERE M = 1 INTERSECT 选择A,B,C,Mdate FROM CTE2 WHERE M = 1WITH CTE1 AS ( SELECT A, B, C, Mdate, ROW_NUMBER() OVER (PARTITION BY A ORDER BY Mdate DESC) As M FROM tblTestData ), CTE2 AS ( SELECT A, B, C, Mdate, ROW_NUMBER() OVER (PARTITION BY B ORDER BY Mdate DESC) As M FROM tblTestData )SELECT A, B, C, MdateFROM CTE1WHERE M = 1INTERSECTSELECT A, B, C, MdateFROM CTE2WHERE M = 1 这篇关于根据列中多个组合的日期选择最近一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 08:30