How can I repeat this query 100 times?How can I prevent SQL injection in PHP?SQL update from one Table to another based on a ID matchCan I concatenate multiple MySQL rows into one field?Inserting multiple rows in a single SQL query?SQL exclude a column using SELECT * [except columnA] FROM tableA?Select n random rows from SQL Server tableInsert, on duplicate update in PostgreSQL?How do I UPDATE from a SELECT in SQL Server?How to query MongoDB with “like”?What are the options for storing hierarchical data in a relational database?

How do I talk to my wife about unrealistic expectations?

How can I use my cell phone's light as a reading light?

Need a non-volatile memory IC with near unlimited read/write operations capability

Passwordless authentication - how and when to invalidate a login code

Is "wissen" the only verb in German to have an irregular present tense?

Why does Trump want a citizenship question on the census?

Draw a diagram with rectangles

How to understand flavors and when to use combination of them?

My professor has told me he will be the corresponding author. Will it hurt my future career?

Why did Robert F. Kennedy loathe Lyndon B. Johnson?

Deck of Cards with Shuffle and Sort functionality

Redirecting stderr using exec

Why am I getting unevenly-spread results when using $RANDOM?

Interpretation of non-significant results as "trends"

run bash scripts in folder all at the same time

US citizen traveling with Peruvian passport

My previous employer committed a severe violation of the law and is also being sued by me. How do I explain the situation to future employers?

Computer name naming convention for security

Can the word "desk" be used as a verb?

This LM317 diagram doesn't make any sense to me

Users forgotting to regenerate PDF before sending it

Strong Password Detection in Python

Write a function

How do I separate enchants from items?



How can I repeat this query 100 times?


How can I prevent SQL injection in PHP?SQL update from one Table to another based on a ID matchCan I concatenate multiple MySQL rows into one field?Inserting multiple rows in a single SQL query?SQL exclude a column using SELECT * [except columnA] FROM tableA?Select n random rows from SQL Server tableInsert, on duplicate update in PostgreSQL?How do I UPDATE from a SELECT in SQL Server?How to query MongoDB with “like”?What are the options for storing hierarchical data in a relational database?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have this query to generate a random number from one table



select DBMS_RANDOM.value as val
from c4_trt
where rownum=1;



Now I want to generate 100 random numbers from this table.



Please note: I want to generate a random number from this specific table, not from dual. But I'm not sure if I can generate a random number from a specific table.



Thanks all!










share|improve this question




























    0















    I have this query to generate a random number from one table



    select DBMS_RANDOM.value as val
    from c4_trt
    where rownum=1;



    Now I want to generate 100 random numbers from this table.



    Please note: I want to generate a random number from this specific table, not from dual. But I'm not sure if I can generate a random number from a specific table.



    Thanks all!










    share|improve this question
























      0












      0








      0








      I have this query to generate a random number from one table



      select DBMS_RANDOM.value as val
      from c4_trt
      where rownum=1;



      Now I want to generate 100 random numbers from this table.



      Please note: I want to generate a random number from this specific table, not from dual. But I'm not sure if I can generate a random number from a specific table.



      Thanks all!










      share|improve this question














      I have this query to generate a random number from one table



      select DBMS_RANDOM.value as val
      from c4_trt
      where rownum=1;



      Now I want to generate 100 random numbers from this table.



      Please note: I want to generate a random number from this specific table, not from dual. But I'm not sure if I can generate a random number from a specific table.



      Thanks all!







      sql oracle






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 22:32









      LionLion

      11 bronze badge




      11 bronze badge






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You stated in your question that you did NOT want to see a solution that utilizes the Oracle's dual dummy table. Unless your table already has 100 + records in the table you are selecting from I currently don't see a way for you to get 100 records showing random numbers unless you use Connect By Level.



          Below I've provided TWO answers that would get you 100 Random Numbers in 100 Rows of output. The FIRST example uses the dual table and Connect By Level using LEVEL to limit the rows CONNECT BY LEVEL <= 100. The SECOND example uses rownum and limits the rows using rownum <= 100.



          Using the dual table



          SELECT LEVEL, floor(dbms_random.value(1,11)) AS rand_num /* Returns random numbers 1 thru 10 */
          FROM dual
          CONNECT BY LEVEL <= 100
          ;


          Using any other table
          This example uses Oracles all_objects Dictionary View as it returns way more than 100 Rows so I decided to work with this but know that any Table/View that returns more than 100 rows will work in this example.



          SELECT floor(dbms_random.value(1,11)) AS rand_num, /* Returns random numbers 1 thru 10 */
          rownum as at_row_num
          FROM all_objects
          WHERE rownum <= 100
          ;


          The Image below shows what the output looks like when using the dual table example.



          enter image description here






          share|improve this answer

























          • thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

            – Lion
            Mar 27 at 16:35


















          1














          Not sure why you need or want to but this will work if you have at least 100
          rows in your table and that's only to keep rownum happy. The table you use is irrelevant.



          select DBMS_RANDOM.value as val from c4_trt where rownum =< 100;





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347345%2fhow-can-i-repeat-this-query-100-times%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You stated in your question that you did NOT want to see a solution that utilizes the Oracle's dual dummy table. Unless your table already has 100 + records in the table you are selecting from I currently don't see a way for you to get 100 records showing random numbers unless you use Connect By Level.



            Below I've provided TWO answers that would get you 100 Random Numbers in 100 Rows of output. The FIRST example uses the dual table and Connect By Level using LEVEL to limit the rows CONNECT BY LEVEL <= 100. The SECOND example uses rownum and limits the rows using rownum <= 100.



            Using the dual table



            SELECT LEVEL, floor(dbms_random.value(1,11)) AS rand_num /* Returns random numbers 1 thru 10 */
            FROM dual
            CONNECT BY LEVEL <= 100
            ;


            Using any other table
            This example uses Oracles all_objects Dictionary View as it returns way more than 100 Rows so I decided to work with this but know that any Table/View that returns more than 100 rows will work in this example.



            SELECT floor(dbms_random.value(1,11)) AS rand_num, /* Returns random numbers 1 thru 10 */
            rownum as at_row_num
            FROM all_objects
            WHERE rownum <= 100
            ;


            The Image below shows what the output looks like when using the dual table example.



            enter image description here






            share|improve this answer

























            • thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

              – Lion
              Mar 27 at 16:35















            2














            You stated in your question that you did NOT want to see a solution that utilizes the Oracle's dual dummy table. Unless your table already has 100 + records in the table you are selecting from I currently don't see a way for you to get 100 records showing random numbers unless you use Connect By Level.



            Below I've provided TWO answers that would get you 100 Random Numbers in 100 Rows of output. The FIRST example uses the dual table and Connect By Level using LEVEL to limit the rows CONNECT BY LEVEL <= 100. The SECOND example uses rownum and limits the rows using rownum <= 100.



            Using the dual table



            SELECT LEVEL, floor(dbms_random.value(1,11)) AS rand_num /* Returns random numbers 1 thru 10 */
            FROM dual
            CONNECT BY LEVEL <= 100
            ;


            Using any other table
            This example uses Oracles all_objects Dictionary View as it returns way more than 100 Rows so I decided to work with this but know that any Table/View that returns more than 100 rows will work in this example.



            SELECT floor(dbms_random.value(1,11)) AS rand_num, /* Returns random numbers 1 thru 10 */
            rownum as at_row_num
            FROM all_objects
            WHERE rownum <= 100
            ;


            The Image below shows what the output looks like when using the dual table example.



            enter image description here






            share|improve this answer

























            • thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

              – Lion
              Mar 27 at 16:35













            2












            2








            2







            You stated in your question that you did NOT want to see a solution that utilizes the Oracle's dual dummy table. Unless your table already has 100 + records in the table you are selecting from I currently don't see a way for you to get 100 records showing random numbers unless you use Connect By Level.



            Below I've provided TWO answers that would get you 100 Random Numbers in 100 Rows of output. The FIRST example uses the dual table and Connect By Level using LEVEL to limit the rows CONNECT BY LEVEL <= 100. The SECOND example uses rownum and limits the rows using rownum <= 100.



            Using the dual table



            SELECT LEVEL, floor(dbms_random.value(1,11)) AS rand_num /* Returns random numbers 1 thru 10 */
            FROM dual
            CONNECT BY LEVEL <= 100
            ;


            Using any other table
            This example uses Oracles all_objects Dictionary View as it returns way more than 100 Rows so I decided to work with this but know that any Table/View that returns more than 100 rows will work in this example.



            SELECT floor(dbms_random.value(1,11)) AS rand_num, /* Returns random numbers 1 thru 10 */
            rownum as at_row_num
            FROM all_objects
            WHERE rownum <= 100
            ;


            The Image below shows what the output looks like when using the dual table example.



            enter image description here






            share|improve this answer















            You stated in your question that you did NOT want to see a solution that utilizes the Oracle's dual dummy table. Unless your table already has 100 + records in the table you are selecting from I currently don't see a way for you to get 100 records showing random numbers unless you use Connect By Level.



            Below I've provided TWO answers that would get you 100 Random Numbers in 100 Rows of output. The FIRST example uses the dual table and Connect By Level using LEVEL to limit the rows CONNECT BY LEVEL <= 100. The SECOND example uses rownum and limits the rows using rownum <= 100.



            Using the dual table



            SELECT LEVEL, floor(dbms_random.value(1,11)) AS rand_num /* Returns random numbers 1 thru 10 */
            FROM dual
            CONNECT BY LEVEL <= 100
            ;


            Using any other table
            This example uses Oracles all_objects Dictionary View as it returns way more than 100 Rows so I decided to work with this but know that any Table/View that returns more than 100 rows will work in this example.



            SELECT floor(dbms_random.value(1,11)) AS rand_num, /* Returns random numbers 1 thru 10 */
            rownum as at_row_num
            FROM all_objects
            WHERE rownum <= 100
            ;


            The Image below shows what the output looks like when using the dual table example.



            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 25 at 23:19

























            answered Mar 25 at 23:13









            Code NoviceCode Novice

            7174 silver badges20 bronze badges




            7174 silver badges20 bronze badges












            • thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

              – Lion
              Mar 27 at 16:35

















            • thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

              – Lion
              Mar 27 at 16:35
















            thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

            – Lion
            Mar 27 at 16:35





            thank you very much! yes, my table c4_trt has 10M rows, but i do want to get a random number generated from this table and repeat 100 times.

            – Lion
            Mar 27 at 16:35













            1














            Not sure why you need or want to but this will work if you have at least 100
            rows in your table and that's only to keep rownum happy. The table you use is irrelevant.



            select DBMS_RANDOM.value as val from c4_trt where rownum =< 100;





            share|improve this answer



























              1














              Not sure why you need or want to but this will work if you have at least 100
              rows in your table and that's only to keep rownum happy. The table you use is irrelevant.



              select DBMS_RANDOM.value as val from c4_trt where rownum =< 100;





              share|improve this answer

























                1












                1








                1







                Not sure why you need or want to but this will work if you have at least 100
                rows in your table and that's only to keep rownum happy. The table you use is irrelevant.



                select DBMS_RANDOM.value as val from c4_trt where rownum =< 100;





                share|improve this answer













                Not sure why you need or want to but this will work if you have at least 100
                rows in your table and that's only to keep rownum happy. The table you use is irrelevant.



                select DBMS_RANDOM.value as val from c4_trt where rownum =< 100;






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 23:10









                Jim CastroJim Castro

                4641 silver badge5 bronze badges




                4641 silver badge5 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347345%2fhow-can-i-repeat-this-query-100-times%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현