Monday, February 24, 2014

Select a random sample of results from an oracle query

select *
   from ( select SCHEDULE_NO, DEPOT
               from SCHEDULE_MASTER
                     where SCHEDULE_NO like '%'
                      order by dbms_random.value )
     where rownum <= 5


SCHEDULE_NO         DEPOT
89D/1                           27
304L/1                          18
333E/1                           22
317G/2                          18
BIAL 9/8                       10


SCHEDULE_NO                   DEPOT
43J/1                                      24
256M/1                                   27
346N/1                                   16
J12/1                                      32
V 500A/2                                 11

For mysql query

select  * from t_employee_details ORDER BY RAND() LIMIT 10;