Sampling Example: Unconditional, Approximate Sample Size - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.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 from the attachment in the left sidebar.