Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 11th, 2004, 01:33 AM
joyce joyce is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 92 joyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 18 sec
Reputation Power: 7
random selection?

How to generate a random selection in oracle??

i do know that in mysql i can use rand().

Reply With Quote
  #2  
Old May 11th, 2004, 03:50 AM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
Hi,

use :

select ...
from sales sample(5) # or from sales sample(5) blocks

the first will sample 5% out of the table whereas the second 4 block randomly.

Good luck.

Reply With Quote
  #3  
Old May 11th, 2004, 04:42 AM
joyce joyce is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 92 joyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 18 sec
Reputation Power: 7
Hi, thanks for ur reply.

i tried something like this..
select * from product sample(5) blocks where rownum < 10

and also

select * from product sample(5) # where rownum < 10

but it returns nothing. pls advise.

Reply With Quote
  #4  
Old May 12th, 2004, 02:03 AM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
Hi Joyce,

the reason you probably not getting anything is because the table doesn't have statistics. what you need to do is:

analyze table .... compute statistics;

(if the table is large you better off replacing the compute statistics with estimate statistics sample 20 percent).

Let me know if it helped.

Galit.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > random selection?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT