Randomied sample

Database
Enthusiast

Randomied sample

Can someone please help

I have a table with

account_number
first name
last name
present balance
outstanding balance
ASR

This table has lets say 2 million records.

i have to take a sample from this table for 1000 accounts.
but the requirment is that the avarage of the ASR of the base table must be very close
to the avarage of ASR of the sample data.

thanks a lot for the help
2 REPLIES
Enthusiast

Re: Randomied sample

try to define value range of ASR, and then sample the records within one specific value range, you need to define the sample number of different range to make it close to avg value.
Enthusiast

Re: Randomied sample

I think you can use ordered analytical functions

SEL
KEY_COL
,AVG(ASR) OVER()
FROM TEST SAMPLE 1000;

instead of 1000, you can probably give a % of record as .15 (for 15% of records).

You can use this information to join back to other table or you can probably do self join.

I think it this should work.

Vinay