Pau Lo
asked on
select xyz records from an oracle table
is there an easy way within oracle (sql*plus) to run a select clause to only select say a sample of 30 rows per database table.
i.e. select (sample of 30) * (all fields)
from mytable
i.e. select (sample of 30) * (all fields)
from mytable
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Even though you already selected an answer to this, you asked for a 'sample' of data. The accepted answers return the first 30 rows you select. This really isn't a sample.
There is a SAMPLE clause in sqlplus that you pass a percentage.
There is also this trick (still uses rownum but against a random order):
select * from
( select * from some_table order by dbms_random.value)
where rownum<=30
There is a SAMPLE clause in sqlplus that you pass a percentage.
There is also this trick (still uses rownum but against a random order):
select * from
( select * from some_table order by dbms_random.value)
where rownum<=30
my understanding was that a random sample set of records was not requested to be output each time the query runs otherwise i would have suggested the use of the dbms_random package stuff. Thanks,
select rownum, a.*
from mytable a
where rownum < 31