Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

SQL Server 2008 Verwenden von RANK zum dynamischen Nummerieren von Zeilen

Dies sollte tun:

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 ;