sql >> Base de Datos >  >> RDS >> Sqlserver

SQL Server 2008 usando RANK para numerar filas dinámicamente

Esto debería hacer:

SELECT rank() OVER (ORDER BY WL.LastName, WL.FirstName) as rank, WL.LastName, WL.FirstName 
FROM  @tblWaitList WL         
INNER JOIN @tblSeminar S 
ON WL.SeminarGuid=S.SeminarGuid     
WHERE S.SeminarID = @SeminarID AND S.SeminarType = @SeminarType         
ORDER BY rank ;