• Don't know if it's any better, but an alternative is: -

    SELECT DateStarted, RowID, ProductID

    FROM (SELECT DateStarted, RowID, ProductID,

    MAX(DateStarted) OVER(PARTITION BY ProductID) AS MaxDateStarted

    FROM #AllData

    ) a

    WHERE a.DateStarted = a.MaxDateStarted

    ORDER BY a.ProductID DESC;


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/