SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
SQL/MX Clauses
HP NonStop SQL/MX Reference Manual—523725-004
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. See SELECT Statement on page 2-178.
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:
 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 
specifies the value of the size for RANDOM sampling by using a percent of the 
result table. The value percent-result must be a numeric literal.
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 










