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