I gave the query:
select dbms_random.value
from table;
How do I get the 25% sample?
I gave the query:
select dbms_random.value
from table;
How do I get the 25% sample?
The select statement allows that.
The sample_clause lets you instruct the database to select from a random sample of data from the table, rather than from the entire table.
Selecting a Sample: Example The following query estimates the number of orders in the orders table:
SELECT COUNT(*) * 10 FROM orders SAMPLE (10); COUNT(*)*10 ----------- 70
Look here
SELECT * FROM (
SELECT temp.*, COUNT(*) OVER () count_rows
FROM temp ORDER BY dbms_random.value)
WHERE rownum <= 0.25 * count_rows;
Another method:
SELECT * FROM (
SELECT mytable.*
,NTILE(4) OVER (ORDER BY DBMS_RANDOM.value)
AS quartile
FROM mytable
)
WHERE quartile = 1;