SQL/ORACLE

[Oracle]랜덤하게 데이터 가져오기

nineDeveloper 2014. 2. 12. 21:49
728x90
반응형

랜덤 select 쿼리라는게 뭘 말하시는건지

아래 문장은 all_objects 에서 임의의 30% row를 리턴해 줍니다.

 

select * from all_objects sample(30)

 

 

 

MOD함수를 사용해서

 

SELECT ABS(MOD(DBMS_RANDOM.RANDOM, 26)) + 65
FROM dual

 

이렇게 하면 되지 않을까요?

원하시는 답인지 모르겠네요.

 

 

******************************

select *

from ( select a.empno, a.ename,b.deptno

from emp a,dept b

where a.deptno = b.deptno

and a.ename like '%'

order by dbms_random.value )

where rownum <= 4

 

 

*************************************************

select * from emp sample(1); 1%이내

 

select * from emp sample(1)

where rownum <= 5;

1%이내에서 5개만가져오기

그외 패키지이용방법등이 있습니다.

728x90
반응형