;WITH cte AS( SELECT *, ROW_NUMBER() OVER (PARTITION BY ProductCode ORDER BY Id DESC) AS rn FROM ProductPriceInfo)SELECT *FROM cteWHERE rn = 1
查询每一组的第一行
原文:http://www.cnblogs.com/871735097-/p/4277057.html