2011-02-03 8 views

Répondre

0
SELECT * 
FROM (
SELECT * , row_number() over(partition by code order by Description) as id 
from yourTable 
) temp 
WHERE id = 1 

Je pense que cela sql server ne

0

Vous devez d'abord choisir une colonne qui détermine ce qui compte comme «le premier résultat. Dans mon exemple, j'ai choisi Description:

SELECT * FROM YourTable first 
WHERE 
    (SELECT COUNT(*) FROM YourTable previous 
    WHERE previous.Code=first.Code AND previous.Description < first.Description) = 0 
Questions connexes