;WITH x AS ( SELECt ID, NAME, [DATE], rn = ROW_NUMBER() OVER (PARTITION BY NAME ORDER BY [DATE] DESC) FROM @TESTABLE)SELECt ID, NAME, [DATE] FROM x WHERe rn = 1 ORDER BY [DATE] DESC;
尽量避免使用保留字(和模糊的列名),例如
[DATE]…
欢迎分享,转载请注明来源:内存溢出
;WITH x AS ( SELECt ID, NAME, [DATE], rn = ROW_NUMBER() OVER (PARTITION BY NAME ORDER BY [DATE] DESC) FROM @TESTABLE)SELECt ID, NAME, [DATE] FROM x WHERe rn = 1 ORDER BY [DATE] DESC;
尽量避免使用保留字(和模糊的列名),例如
[DATE]…
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)