Sampling Example | Teradata Vantage - Sampling Example: Unconditional, Approximate Sample Size - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example uses the ApproxSampleSize syntax element and a summary (DIMENSION) table as inputs.

Input

summary
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.