Answer the question
In order to leave comments, you need to log in
How in Oracle or Teradata to split all table rows into N equal RANDOM samples?
By a random sample I understand the uniform distribution of the elements of a given sample over the general population.
In Teradata, you can get a random sample of size k like this:
SELECT *
FROM t1
SAMPLE RANDOMIZED ALLOCATION k;
Answer the question
In order to leave comments, you need to log in
select t1. *, ntile(N) over (order by dbms_random.random) nbatch from t1
In practice, using the Monte Carlo method, we mark numbers from a random interval of the table entry and take the portion of interest according to this random metric. Since random works for us according to the uniform distribution law, then you will receive a portion of data of approximately the expected length.
select *
from (
select t.*, dbms_random.value(0, 100) rnd
from table t
) A
where A.rnd <= 30 -- выбираем примерно 30% случайных записей от ген. выборки
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question