TD_UnivariateStatistics Example | UnivariateStatistics - Example: Using TD_UnivariateStatistics to Determine Mean, Median, and Mode - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Every complete example in this document is available in a zip file that you can download. The zip file includes a SQL script file that creates the input tables for the examples. If you are reading this document on https://docs.teradata.com/, you can download the zip file from the attachment in the left sidebar.

TD_UnivariateStatistics InputTable: titanic_train

passenger survived  name                                 gender age  fare       
--------- --------  ----                                 ------ ---  ----       
       97        0  Goldschmidt; Mr. George B            male   71   34.6542        
      488        0  Kent; Mr. Edward Austin              male   58   29.7       
      505        1  Maioni; Miss. Roberta                female 16   86.5        
      631        1  Barkworth; Mr. Algernon Henry Wilson male   80   30        
      873        0  Carlsson; Mr. Frans Olof             male   33    5

TD_UnivariateStatistics SQL Call

SELECT * FROM TD_UnivariateStatistics (
  ON titanic_train AS InputTable
  USING
  TargetColumns ('age','fare')
  Stats ('MEAN', 'MEDIAN', 'MODE')
) AS dt;

TD_UnivariateStatistics Output

ATTRIBUTE StatName StatValue 
--------- -------- --------- 
age       MEAN      5.16000000000000E 001
age       MEDIAN    5.80000000000000E 001
age       MODE      1.60000000000000E 001
fare      MEAN      3.71708400000000E 001
fare      MEDIAN    3.00000000000000E 001
fare      MODE      5.00000000000000E 000