'SQL Query to output single column with below values in each row - 1 2 2 3 3 3 4 4 4 4 [closed]

Need to write SQL query for getting below output with the given input table:

Input Table:

Col1
1
2
3

Output:

Col1
1
2
2
3
3
3
sql


Solution 1:[1]

WITH CTE(NN)AS
(
  SELECT 1 UNION ALL
  SELECT 2 UNION ALL
  SELECT 3 UNION ALL
  SELECT 4 UNION ALL
  SELECT 5
)
SELECT C.NN 
FROM CTE AS C
CROSS JOIN CTE C2
WHERE C2.NN<=C.NN

CTE is your input table

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergey