Sampling a Table

From TekiWiki

Jump to: navigation, search

This whole wiki has now moved to http://www.springboardsolutions.com/wiki

Go to this page Sampling a Table

(Created page with "Getting a few random rows from as Oracle Database table can be done in many different ways. This will just select the first ten rows Oracle comes across in the table: <pre> ...")
Line 7: Line 7:
where
where
rownum<=10
rownum<=10
-
/
 
</pre>
</pre>
They are likely to all be inserted at a similar time and therefore all similar. If you need a cross section:
They are likely to all be inserted at a similar time and therefore all similar. If you need a cross section:
 +
<pre>
 +
select *
 +
from iso_country
 +
sample (10) -- percentage of rows to display
 +
</pre>
 +
 +
The percentage of rows is not precise, there are 249 rows in the sample iso_country table, but the 10% sample count has given a range from 15 - 31 rows:
 +
 +
<pre>
 +
select count(*)
 +
from iso_country
 +
sample (10) -- percentage of rows to display
 +
</pre>

Revision as of 22:39, 19 August 2011

Personal tools