Hi EmadKhan,
Refer below query.
SQL
DECLARE @Counter INT,@StartYear INT, @EndYear INT
SET @Counter = 1
SET @StartYear = YEAR(GETDATE())
SET @EndYear = 1970
DECLARE @Test AS TABLE(StartRange INT,EndRange INT)
DECLARE @StartRange INT,@EndRange INT
SET @StartRange = @StartYear
WHILE (@Counter <= (@StartYear - @EndYear))
BEGIN
SET @EndRange = @StartRange - 9
INSERT INTO @Test (StartRange,EndRange) VALUES (@StartRange,@EndRange)
SET @StartRange = @EndRange - 1
SET @Counter = @Counter + 10
CONTINUE;
END
SELECT CONVERT(VARCHAR,StartRange) + '-' + CONVERT(VARCHAR,EndRange) AS 'Range' FROM @Test
Output
2019-2010
2009-2000
1999-1990
1989-1980
1979-1970