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

SQL Server 2008 usando RANK para numerar linhas dinamicamente


Isso deve fazer:
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 ;