Re: can you solve this?

From: Alexander Penev <alex_at_cska.net>
Date: Mon, 21 Aug 2000 14:19:24 +0200
Message-ID: <39A11E4C.262B95EE_at_cska.net>


My solution would be:
Make a table with only one field of number Populate it with 500 random generated numbers between 1 and count(*) from customer table
then:
select a.* from (select b.*, rownum rnum from customer b) a, random_table b where a.rnum=b.num

If your random function is random enough, you the shares of the age groups should represent nearly their shares in the big table... HTH Hagai Katz wrote:

> Here's a tough one... Oracle support failed to solve it.
>
> 1. let's start simple: How can you derive a sample of a predefined number of
> rows from a table, when the lines are picked RANDOMLY?
> 2. Now let's make it tougher:
> how can you do a layered sample, in which you take a RANDOMLY selected
> number of lines from different groups of rows in a table, which are defined
> by a column in the table, and the number of rows sampled from each group
> must be determined according to the relative size of that group in the
> table.
> For example: I have a table with clients, distinguished by a column called
> AGE into age groups, and I want to take a random sample of 500 clients, in
> which every age group will be represented according to it's relative weight
> in my clients group. how do I do that?
>
> any ideas?
> Best solutions will be circulated around...
>
> PS - Oracle 8i please...
Received on Mon Aug 21 2000 - 14:19:24 CEST

Original text of this message