SQL/MX 2.x Reference Manual (G06.24+, H06.03+)

SQL/MX Clauses
HP NonStop SQL/MX Reference Manual523725-004
7-12
Examples of SAMPLE
27000.12
136000.00
37000.40
...
--- 50 row(s) selected.
Return the SALARY of 50 sales people. In this case, the table is clustered on
EMPID. If the optimizer chooses a plan to access rows using the primary access
path, the result consists of salaries of the 50 sales people with the smallest
employee identifiers.
SELECT salary
FROM salesperson
SAMPLE FIRST 50 ROWS;
SALARY
-----------
175500.00
137000.10
136000.00
138000.40
75000.00
90000.00
...
--- 50 row(s) selected.
Return the SALARY of the youngest five sales people, skip the next 15 rows, and
repeat this process until there are no more rows in the intermediate result table.
Note that you cannot specify periodic sampling with the sample size larger than the
period.
SELECT salary
FROM salesperson
SAMPLE PERIODIC 5 ROWS EVERY 20 ROWS SORT BY age;
SALARY
-----------
90000.00
90000.00
28000.00
27000.12
136000.00
36000.00
...
--- 17 row(s) selected.
In this example, there are 62 rows in the SALESPERSON table. For each set of 20
rows, the first five rows are selected. The last set consists of two rows, both of
which are selected.