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!

Conditional select and dbms_random problem

708211Jun 22 2009 — edited Jun 23 2009
I have the following query:
select *
  from (select employee_id, email,
               case
                  when dbms_random.value () < 0.5
                     then 'S'
               end as status
          from hr.employees)
 where status is not null
The inner query does what I expect, namely return all employee records and about 50% of them have the 'S' status. Then I try to use the outer query to filter only employees with status 'S'. What I get, in this case, is about half the time no rows returned and about half the time all rows returned (including those with null status).

Any ideas?

Edited by: user6570265 on Jun 22, 2009 3:19 PM
This post has been answered by SeánMacGC on Jun 23 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2009
Added on Jun 22 2009
35 comments
1,395 views