Repeating numbers in a sequence as n=many times as the number

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.

Another way, probably what i was originally trying to figure out. It's backwards, but it relies on rownum, and the complete processing of the TABLE:
SQL> SELECT
  2     A
  3  FROM
  4     (SELECT Rownum A FROM Dual CONNECT BY Rownum <= 5)
  5  CONNECT BY
  6     Rownum BETWEEN  ((A * A) - A) /2 + 1 AND ((A * A) + A) / 2 - 1;
         A
         1
         2
         2
         3
         3
         3
         4
         4
         4
         4
         5
         5
         5
         5
         5
15 rows selected.
[pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

Maybe you are looking for

  • Can you use a php variable to filter a recordset?

    I've got a table of 'events', which have a description and more importantly for this a month ID number. (1-12 for the months of the year, when the event takes place) . I've used php's date function on a page to fund out numerically what month it is n

  • Itunes 10.5.1 doesn't open with windows 7 64 bit

    i have just purchased a new HP laptop with windows 7 64bit and have installed itunes. all the files have installed correctly but the program doesnt open. any ideas ?

  • Address Book contacts disappeared after Mac OS X 10.4.8 upgrade

    I opened my address book this morning to find it blank except for me and Apple. I did not delete anything at any time - the only thing I can think that happened between now and the last time everything was there was the 10.4.8 upgrade process. The li

  • MacMini as centre of Home Cinema System

    I am looking to use a MacMini as the centre of my Home Cinema system. The intention is to connect the MacMini to my existing Sony Projector (VLP CX85). I know this is not the best projector for this kind of things, but it is one I have had for some t

  • Safari ignoring proxy username and password

    I have an iPad2 and an iPad1. If I enter a username and password in the proxy settings for our company WiFi network, the iPad1 works flawlessly, the iPad2, however, ignores the username and password, and prompts for it onscreen. If I enter the userna