标签:
SELECT *FROM (SELECT RowNumber =row_number() OVER (PARTITION BY TaskID ORDER BY ProduceDate DESC), * FROM dbo.ShippingDocument)tWHERE t.RowNumber< 2 ORDER BY t.TaskID ASC
2、采用游标方法。
SQL中Group分组获取Top N方法实现
原文地址:http://www.cnblogs.com/onmywaying/p/4775002.html