TD_UnivariateStatistics Function Example | Teradata Vantage - TD_UnivariateStatistics Example - Teradata® Database

Database Analytic Functions

Product
Teradata® Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/wnd1589838592459.ditamap
dita:ditavalPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/ayr1485454803741.ditaval
dita:id
B035-1206
lifecycle
previous
Product Category
Teradata Vantage™

InputTable: titanic_train

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.

passenger survived  name                                 sex    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

SQL Call

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

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