This example uses the ApproxSampleSize syntax element and a summary (DIMENSION) table as inputs.
Input
- data: score_category, as in Sampling Example: Unconditional, Single Sample Rate
- summary: created from score_category by this query:
SELECT stratum, COUNT(*) AS stratum_count FROM score_category GROUP BY stratum;
stratum | stratum_count |
---|---|
very good | 9 |
excellent | 14 |
fair | 77 |
SQL Call
SELECT * FROM Sampling ( ON ( SELECT stratum, COUNT(*) AS stratum_count FROM score_category GROUP BY stratum ) AS SummaryTable DIMENSION ON score_category PARTITION BY ANY USING ApproxSampleSize (10) Seed (2) ) AS dt ORDER BY id;
Output
id score stratum -- ----- --------- 9 65.0 fair 23 14.0 fair 59 89.0 very good 61 6.0 fair 71 59.0 fair 72 79.0 fair 75 66.0 fair 77 51.0 fair 86 6.0 fair 89 31.0 fair 95 84.0 very good
Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.