CUME_DIST Function Example | Teradata Vantage - 17.00 - 17.05 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
17.05
Published
June 2020
Language
English (United States)
Last Update
2021-01-30
dita:mapPath
tpt1555966086716.ditamap
dita:ditavalPath
lze1555437562152.ditaval

The following SELECT statement:

SELECT lname, serviceyrs,
 CUME_DIST()OVER(ORDER BY serviceyrs)
 FROM schooltbl
 GROUP BY 1,2;

returns the cumulative distribution by service years for teachers listed in schooltbl.

lname serviceyrs CUME_DIST
Adams 10 0.333333
Peters 10 0.333333
Murray 10 0.333333
Rogers 15 0.444333
Franklin 16 0.555333
Smith 20 0.888889
Ford 20 0.888889
Derby 20 0.888889
Baker 20 1.000000