Oracle SAMPLE syntax Application

Source: Internet
Author: User

The Sample function is used to support data mining. The Sample function allows data analysis to be performed on the Sample data, rather than on the entire table.

Select record 10%
Select * from atest sample (11)
Select record 0.1%
Select * from atest sample (0.1)

Select 1% records based on data blocks
Select * from atest sample block (1)

The difference between using data block selection and using record rows: using data block selection indicates that sample collection is based on data blocks. That is to say, if a sample is collected as a sample,

All records in the data block are samples.

Sample statistics are collected based on statistics. There is a probability problem and it may not be completely accurate. For example, if you want to retrieve 50% of records, but it may actually return 49% of the records to you, it may also return 51% of the record sets to you.

For example

If table T1 has data blocks B1, B2
B1 records R1, R2, R3, R4, R5
B2 records R6, R7, R8, R9, R10

If you use the following SQL statement to select 50% of the data
Select * from atest sample block (50)

The returned result may be a record of data block B1.
R1, R2, R3, R4, R5
It may also be a data block B2 record.
R6, R7, R8, R9, R10
Or the record set may not be returned.

If you use the following SQL statement to select 50% of the data
Select * from atest sample (50)

The returned result may be
R2, R3, R5, R8, R9
It may also look like the following:
R1, R3, R4, R8

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.