1.1 - 8.10 - Sampling Example: Unconditional, Approximate Sample Size - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

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.