Histogram Example 3: BinSize, StartValue, EndValue - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
lmf1502735330121
Product Category
Teradata Vantage

You specify one bin size and start and end values, and the output is grouped for each values of grouping variable (cyl).

Input

SQL Call

DROP TABLE IF EXISTS cars_hist_out;

SELECT * FROM Histogram (
  ON cars_hist AS InputTable
  OUT TABLE OutputTable (cars_hist_out)
  USING
  StartValue (20)
  BinSize (50)
  EndValue (400)
  Inclusion ('right')
  TargetColumn ('hp')
  GroupByColumns ('cyl')
) AS dt;

Output

output_table output_columns
specified in OutputTable argument "cyl" bin bin_start bin_end bin_count bin_percent

This query returns the following table:

SELECT * FROM cars_hist_out ORDER BY 1;
cars_hist_out
cyl bin bin_start bin_end bin_count bin_percent
4 0 20 70 5 45.45
4 1 70 120 6 54.55
4 2 120 170 0 0.00
4 3 170 220 0 0.00
4 4 220 270 0 0.00
4 5 270 320 0 0.00
4 6 320 370 0 0.00
4 7 370 400 0 0.00
6 0 20 70 0 0.00
6 1 70 120 4 57.14
6 2 120 170 2 28.57
6 3 170 220 1 14.29
6 4 220 270 0 0.00
6 5 270 320 0 0.00
6 6 320 370 0 0.00
6 7 370 400 0 0.00
8 0 20 70 0 0.00
8 1 70 120 0 0.00
8 2 120 170 2 14.29
8 3 170 220 7 50.00
8 4 220 270 4 28.57
8 5 270 320 0 0.00
8 6 320 370 1 7.14
8 7 370 400 0 0.00