Thanks!
Oracle/SQL help
Moderator: Community Team
Forum rules
Please read the Community Guidelines before posting.
Please read the Community Guidelines before posting.
Oracle/SQL help
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!
Thanks!
-
Darkfire001
- Posts: 139
- Joined: Mon Jan 23, 2006 4:37 pm
- Location: Cary, NC
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.
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!
Thanks!