Du kan använda ntile .
Lite exempelkod:
declare @NumberOfStudents int
declare @StudentsPerGroup int
set @StudentsPerGroup = 10
set @NumberOfStudents = 104
select StudentID,
ntile(@NumberOfStudents / @StudentsPerGroup) over(order by StudentID) as GroupID
from Students
Testa det på SE-Data .