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

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript