Oracle/SQL help

Posted:
Thu May 18, 2006 12:06 pm
by wicked
Anyone familiar with writing SQL scripts? Is there anyway I can get a random sample from a script? Right now, I'm spooling a huge list, exporting to excel and doing it there. Takes forever to generate the list, so was wondering if SQL could do it for me.
Thanks!


Posted:
Thu May 18, 2006 12:33 pm
by Darkfire001
When you say generate random sample, do you mean just pull some particular fields or a row out and generate it from that? There are a variety of ways, but an easy way would be just use "numrows" to find total rows, set that as the limit for a random number, and then pull a field based on the primary key. Thats a jiggy-rigged way to do it since if you have an incomplete dataset you'd have some issues, but thats the easiest method I can think of off the top of my head.

Posted:
Thu May 18, 2006 12:53 pm
by wicked
I'm generating a huge list of ID numbers (thousands+) through a SQL script, of which I need to pull out 100 random ID's. I'm doing this for 6 different data sets. It's been spooling for about an hour now...LOL. I was hoping there was a way I could have sql pick 100 random ID's that meet set criteria w/o even generating the list (or so that I didn't have to see it and have it take hours). Make sense?
Thanks!


Posted:
Thu May 18, 2006 2:58 pm
by wicked
nevermind, I found a way to limit my list another way ... thanks!

Posted:
Fri Dec 14, 2007 9:05 pm
by blackjoke
Out of curiosity did you limit your list length or find a way of getting a specific number of random selections?