Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generate unique random number

XandotAug 1 2017 — edited Aug 1 2017

Hello,

I'm trying to generate a unique random number with below query:

select trunc(dbms_random.value(1,12)) from dual connect by rownum <= 5;

but this query return duplicate values and if I add distinct then it returns less number of records means less than 5 records.

I want to generate a unique random number based on no. of rows like in above example 5 is max no of records, so it should generate 5 unique random values.

Please help me out.

Thanks in advance!!

This post has been answered by Marwim on Aug 1 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2017
Added on Aug 1 2017
19 comments
10,535 views