sql - Oracle 11g: union all with dbms_random -
i'm trying write sql statement in oracle 11g randomly select 5000 records union of 2 different tables same columns:
select * ( select ename, job emp1 union select ename, job emp2 order dbms_random.value() ) rownum <= 5000
and when run it, error ora-01785: order item must number of select-list expression. when remove second table works fine. but, need select randomly 2 tables, first union them, order them randomly , select 5000 of them.
or maybe there other approach same result?
tnx help.
your order applies second part of union - you'll have perform union first , apply order by:
select * ( select * ( select ename, job emp1 union select ename, job emp2 ) order dbms_random.value() ) rownum <= 5000
Comments
Post a Comment