DENSE_RANK Function Example (ANSI) | 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,
 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