Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

SQL Select Distinto 2 Top 2

SELECT DISTINCT TOP 2 PartId, IdNumber, Length
FROM
(   SELECT PartId, IdNumber, Length, ROW_NUMBER() over(partition by IdNumber order by Length) Orden
    FROM [Ayuda]
) A
WHERE A.Orden = 1
ORDER BY Length