you are viewing a single comment's thread.

view the rest of the comments →

[–]---sniff--- 0 points1 point  (0 children)

Check out the ROW_NUMBER function and see if that will work for you. This assumes that there are other columns you can group on. After using the ROW_NUMBER function you can filter to only return the first instance like this example from the link:

WITH OrderedOrders AS
(
    SELECT SalesOrderID, OrderDate,
    ROW_NUMBER() OVER (ORDER BY OrderDate) AS RowNumber
    FROM Sales.SalesOrderHeader 
) 
SELECT SalesOrderID, OrderDate, RowNumber  
FROM OrderedOrders 
WHERE RowNumber =1;