Chapter 39 - Sample

“The universe extends beyond the mind of man, and is more complex than the small sample one can study.”

- Kenneth L. Pike

The SAMPLE Function and Syntax

The syntax for the SAMPLE function:

 

SAMPLE [ WITH REPLACEMENT ]
[ RANDOMIZED ALLOCATION ]
              [ WHEN <condition>  THEN ]
              {<number-of-rows> | <percentage>}
[...,<number-of-rows> | <percentage>]
              [ ELSE {<number-of-rows> |
<percentage }   END ]

 

 

 

The Sampling function (SAMPLE) permits a SELECT to randomly return rows from a Teradata database table. It allows the request to specify either an absolute number of rows or a percentage of rows to return. Additionally, it provides an ability to return rows from multiple samples.

SAMPLE Function Examples

 

 

 

The above example ...

Get Tera-Tom's 1000 Page e-Book on Teradata Architecture and SQL, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.