DECLARE @StartDate DATE = '2019-12-17'; DECLARE @EndDate DATE = '2021-05-01' declare @Edate date declare @sdate date set @Edate = DATEADD(day, 30, @StartDate) set @sdate = @StartDate WHILE (@Edate <= @EndDate) BEGIN print 'start' print @sdate print @Edate set @sdate = @Edate set @Edate = DATEADD(day, 30, @sdate); print @sdate print @Edate print 'end' END
In SQL server by using function NT ILE 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).
Comments
Post a Comment