Example

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

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

The following SELECT statement:

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

returns the ordered ranking by service years for teachers listed in schooltbl.

lname serviceyrs DENSE_RANK
Adams 10 1
Peters 10 1
Murray 10 1
Rogers 15 2
Franklin 16 3
Smith 20 4
Ford 20 4
Derby 20 4
Baker 25 5