Posts

Showing posts with the label SAMPLE functions

3 Uses of SAMPLE function in Teradata

Image
Usage-1 It returns a rows randomly from Teradata database. Syntax for SAMPLE function: SAMPLE [WITH REPLACEMENT]    [RANDOMIZED ALLOCATION]                  [WHEN <condition>  THEN]                  {<number-of-rows> | <percentage>}    […,<number-of-rows> | <percentage>]                  [ELSE {<number-of-rows> |    <percentage }   END] Usage 2 It allows the user to get absolute number of rows or percentage of rows. Usage 3 It also allows the rows to get from multiple samples How to get random rows from a table: SELECT * from sample_table SAMPLE 5; How to get certain percentage of rows: SELECT * from sample_table SAMPLE .30; How to get multiple SAMPLE data from a single tables with out duplicates: SELECT * from sample_...