NTILE

0

Please login or register to vote for this query.

(click on this box to dismiss)

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

declare @NumberOfStudents int
declare @StudentsPerGroup int

set @StudentsPerGroup = 10
set @NumberOfStudents = 104

select number, ntile((@NumberOfStudents / @StudentsPerGroup)+1) over(order by number) as GroupID
from master..spt_values
where type = 'P' and
      number between 1 and 104

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results