I gave myself a small puzzle, to try to get the numbers 1-5 repeating as many times as their values: 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5
My first attempt was quite simple. But i do not understand the results. Can someone explain to me why these are the results?
SQL> SELECT
2 Rownum,
3 A
4 FROM
5 (SELECT Rownum A FROM Dual CONNECT BY Rownum <= 5)
6 CONNECT BY
7 Rownum <= A;
ROWNUM A
---------- ----------
1 1
2 2
3 3
4 4
5 5
6 2
7 3
8 4
9 5
9 rows selected.