Split rows into equal number of records per group in sql server

 In SQL server by using function NTILE we can split the equal number of records from a table to number of groups

SELECT *,NTILE(5) over( ORDER by Id) GroupNo
from Table

Here records will be assigned to 5 groups (Group No: 1,2,3,4,5).


Popular posts from this blog

List of special Characters in HTML

Get Random alphanumeric number with specific length using SQL Server