Example: Finding Differences Between RANK(ANSI) and DENSE_ RANK(ANSI) - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following SQL statement illustrates the difference between RANK(ANSI) and DENSE_RANK(ANSI), returning the RANK and DENSE_RANK for sales_person by sales_region and sales_amount.

SELECT sales_person, sales_region, sales_amount,
 RANK() OVER
    (PARTITION BY sales_region ORDER BY sales_amount DESC) as "Rank",
 DENSE_RANK() OVER
    (PARTITION BY sales_region ORDER BY sales_amount DESC) as "DenseRank"
 FROM sales_table;
sales_person sales_region sales_amount Rank DenseRank
Garabaldi East 100 1 1
Baker East 100 1 1
Fine East 89 3 2
Adams East 75 4 3
Edwards West 100 1 1
Connors West 99 2 2
Davis West 99 2 2
Russell West 50 4 3