根据输入生成序列号

Generate Series number depend on Input

请告诉我如何在 SQL 中生成以下系列,我有输入并需要输出,例如: This is my Input and needed output

你可以这样使用FLOOR

;WITH temp AS
(
   SELECT row_number() over(ORDER BY n.t) AS Input
   FROM (VALUES (1),(2), (3),(4),(5),(6),(7),(8),(9),(10)) AS n(t)
   CROSS JOIN (VALUES (1),(2), (3),(4),(5),(6),(7),(8),(9),(10)) AS n1(t)
) -- return input table  from 0 --> 100
SELECT t.Input, (FLOOR((t.Input - 1)/15) + 1) *15 AS Output
FROM temp t

演示 link:http://rextester.com/NYZ63298