CUME_DIST Function Example | Teradata Vantage - 17.10 - Example - Advanced SQL Engine - Teradata Database

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

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1145-171K
Language
English (United States)

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