SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Clauses
HP NonStop SQL/MX Reference Manual540440-003
7-17
Examples of SAMPLE
This query shows an example of stratified sampling where the conditions are not
mutually exclusive:
SELECT *
FROM sales
SAMPLE RANDOM
BALANCE WHEN amount > 10000 THEN 100 PERCENT
WHEN product = 'PCGOLD, 30MB' THEN 25 PERCENT
WHEN region = 'W' THEN 40 PERCENT
ELSE 10 PERCENT
END;
EMPID PRODUCT REGION AMOUNT
----- -------------------- ------ -----------
1 PCGOLD, 30MB E 30000.00
23 PCDIAMOND, 60MB W 40000.00
29 GRAPHICPRINTER, M1 N 11000.00
32 GRAPHICPRINTER, M2 S 15000.00
39 GRAPHICPRINTER, M3 S 20000.00
75 LASERPRINTER, X1 W 42000.00
... ... ... ...
--- 30 row(s) selected.