我有这样的声明:
select REFNUMBER, SomeDate, Somecolumn1, Somecolumn2 from Table
如何选择与REFNUMBER分组的最低日期关联的行?
使用ROW_NUMBER()分析功能:
ROW_NUMBER()
SELECT * FROM ( SELECT REFNUMBER, SomeDate, Somecolumn1, Somecolumn2, ROW_NUMBER() OVER ( PARTITION BY REFNUMBER ORDER BY SomeDate ) As rn FROM Table ) WHERE rn = 1