How to Select Random using Oracle


Working on Employees Table :

Query :


select * from (select * from Employees ORDER BY dbms_random.value ) where rownum <= 10

Results :

143 Randall Matos RMATOS
147 Alberto Errazuriz AERRAZUR
152 Peter Hall PHALL
135 Ki Gee KGEE
193 Britney Everett BEVERETT
122 Payam Kaufling PKAUFLIN
130 Mozhe Atkinson MATKINSO
181 Jean Fleaur JFLEAUR
110 John Chen JCHEN
105 David Austin DAUSTIN
Every time you will run same Query you will have new results

i wish this can help you in your Development Process

Thanks,

Comments

Popular posts from this blog

SQL Interview Questions

Manage Your Database Connection

Number of Days in Current Month