title: Oracle creating N rows per value
body: <p>How can I modify the CTE below to INSERT rows into a new table T.</p>
  <p>Based on the output below for table T I should have 4 rows for employee_id =1, 1 row for employee_id=3 and
  2 rows for employee_id=7</p>
  <pre><code>CREATE TABLE T
    (seq_num integer  GENERATED BY DEFAULT AS IDENTITY (START WITH 1) NOT NULL,
     employee_id NUMBER(6));
  
  
   CREATE TABLE  employees (
  employee_id NUMBER(6)
   );
  
  INSERT INTO employees 
  (employee_id)
  VALUES (1);
  
  INSERT INTO employees 
  (employee_id)
  VALUES (3);
  
  INSERT INTO employees 
  (employee_id)
  VALUES (7);
  
  with rws as (
   select level rn
   from   dual
   connect by level &lt;= 5
  ), emps as (
     select /*+ 
   materialize */e.*, 
  round    ( 
  
  dbms_random.value(1,5) ) n
    from   employees e
    )
    select employee_id, count (*) rw_count
   from   rws
   join   emps e
   on     rn &lt;= n
  group  by employee_id
  Order by employee_id;
  
  EMPLOYEE_ID    RW_COUNT
   1    4
   3    1
   7    2
  </code></pre>