SQL/MX 2.x Reference Manual (H06.10+, J06.03+)

SQL/MX Clauses
HP NonStop SQL/MX Reference Manual544517-008
7-8
SAMPLE Clause
SAMPLE Clause
Considerations for SAMPLE
Examples of SAMPLE
The SAMPLE clause of the SELECT statement specifies the sampling method used to
select a subset of the intermediate result table of a SELECT statement. The
intermediate result table consists of the rows returned by a WHERE clause or, if there
is no WHERE clause, the FROM clause. The SAMPLE clause always uses READ
UNCOMMITTED access mode. It overrides the user specified access mode. See
SELECT Statement on page 2-196.
SAMPLE is an SQL/MX extension.
RANDOM percent-size
directs NonStop SQL/MX to choose rows randomly (each row having an unbiased
probability of being chosen) without replacement from the result table. The
sampling size is determined by the percent-size, defined as:
SAMPLE sampling-method
sampling-method is:
RANDOM percent-size
| FIRST rows-size
[SORT BY colname [ASC[ENDING] | DESC[ENDING]]
[,colname [ASC[ENDING] | DESC[ENDING]]]...]
| PERIODIC rows-size EVERY number-rows ROWS
[SORT BY colname [ASC[ENDING] | DESC[ENDING]]
[,colname [ASC[ENDING] | DESC[ENDING]]]...]
percent-size is:
percent-result PERCENT [ROWS
| {CLUSTERS OF number-blocks BLOCKS}]
| BALANCE WHEN condition
THEN percent-result PERCENT [ROWS]
[WHEN condition THEN percent-result PERCENT [ROWS]]...
[ELSE percent-result PERCENT [ROWS]] END
rows-size is:
number-rows ROWS
| BALANCE WHEN condition THEN number-rows ROWS
[WHEN condition THEN number-rows ROWS]...
[ELSE number-rows ROWS] END