Purpose
Reduces the number of rows to be considered for further processing by returning one or more samples of rows specified either as a list of fractions of the total number of rows or as a list of numbers of rows from the SELECT query.
Syntax
Syntax Elements
- SAMPLE
- Introduction to a clause that permits sampling of rows in the SELECT statement.
- WITH REPLACEMENT
- Whether sampling is done by returning each sampled row to the table for possible redundant sampling or by withholding sampled rows from resampling.
- RANDOMIZED ALLOCATION
- Rows are sampled randomly across AMPS. Otherwise, rows are sampled proportionate to the number of qualified rows per AMP (proportional allocation).
- fraction_description
- Any set of unsigned floating point constant numbers in the closed interval (0,1) that specifies the percentage of rows to be sampled for a true search condition.
- count_description
- Set of positive integer constants that specifies the number of rows to be sampled for a true search condition.
- WHEN
- Test a set of conditions for truth.
- search_condition
- Evaluation predicate that defines each homogeneous subgroup in the sample set.
- THEN
- Apply the specified sampling fraction description or count description to the sample.
- ELSE
- Apply the specified sampling fraction description or count description to the sample if none of the WHEN condition predicates evaluates to true.
- END
- Termination of the WHEN … THEN … ELSE clause.
ANSI Compliance
The SAMPLE clause is a Teradata extension to the ANSI SQL:2011 standard.