Generate test data distrubution in Oracle DB What I want to do is to generate test data as follows

table
t1 (id number, colA date, colB number).
Where
"id" is unique,
"colA" is a date incremented every 15 minutes,
"colB" is a number

Condition: value from colA should be repeated random n times.
This is what I've managed to come up with so far:

    SELECT rownum id, TO_DATE('01-MAY-2015') + ROWNUM/24/4 - 1 AS colA, trunc(100*exp(dbms_random.normal)) AS colB
    FROM (
        SELECT ROWNUM FROM (
            SELECT 1 FROM DUAL
            CONNECT BY LEVEL &lt;= (TO_DATE('01-SEP-2015') - TO_DATE('01-MAY-2015'))*24*4
        )
    );


And how it should look like 

Example:

ID      colA                    colB
=====   ====================    =====
11089   23-AUG-2015 12:15:00    75667
11090   23-AUG-2015 12:15:00    64552
11091   23-AUG-2015 12:15:00    26633
11092   23-AUG-2015 12:15:00    86463
11093   23-AUG-2015 12:30:00    77364
11094   23-AUG-2015 12:30:00    2233
11095   23-AUG-2015 12:30:00    32213
11096   23-AUG-2015 12:45:00    73112
11097   23-AUG-2015 13:00:00    1238
11098   23-AUG-2015 13:00:00    8222
Specify n:

variable n number;
exec :n := 4;


Generate data:

select
  rownum as ID,
  colA,
  trunc(dbms_random.value(0, 100000) + 1) as colB
from
  (
  select /*+ no_merge */ 
    colA, 
    decode(rn, 1, 1, round(dbms_random.value(0, 1))) as keep 
  from ( select date'2015-05-01' + rownum/24/4 -1 as colA from dual 
         connect by level &lt;= (date'2015-09-01' - date'2015-05-01') * 24 * 4)
  cross join ( select rownum rn from dual connect by level &lt;= :n)
  )
where keep = 1
;


Sample output:

     ...
     29583 2015-08-30 22:00:00      42206
     29584 2015-08-30 22:00:00      51279
     29585 2015-08-30 22:15:00      17186
     29586 2015-08-30 22:15:00      60113
     29587 2015-08-30 22:15:00      25121
     29588 2015-08-30 22:30:00      46922
     29589 2015-08-30 22:45:00      14382
     29590 2015-08-30 22:45:00      62753
     29591 2015-08-30 23:00:00      14412
     29592 2015-08-30 23:00:00      72185
     29593 2015-08-30 23:00:00      84287
     29594 2015-08-30 23:00:00      34380
     29595 2015-08-30 23:15:00      20976
     29596 2015-08-30 23:15:00       4267
     29597 2015-08-30 23:30:00      79833
     29598 2015-08-30 23:30:00      42456
     29599 2015-08-30 23:30:00      76322
     29600 2015-08-30 23:45:00      85577
     29601 2015-08-30 23:45:00      41267
     29602 2015-08-30 23:45:00      32404
     29603 2015-08-31 00:00:00      89354
     29604 2015-08-31 00:00:00      45470

29604 rows selected.