请让我知道如何在SQL中生成以下系列,我输入并需要输出如: This is my Input and needed output
答案 0 :(得分:0)
您可以像这样使用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