Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

SQL Server 2008 Utilizzo di RANK per numerare dinamicamente le righe

Questo dovrebbe fare:

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 ;