DENSE_RANK Function Syntax (ANSI) | Teradata Vantage - DENSE_RANK Function Syntax (ANSI) - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantage™
DENSE_RANK() OVER (
  [ PARTITION BY column_reference [,...] ] 
  ORDER BY value_spec [,...]
  [ RESET WHEN condition ]
)

Syntax Elements

OVER
Specifies how values are grouped, ordered, and considered when computing the cumulative, group, or moving function.
Values are grouped according to the PARTITION BY BEGIN and RESET WHEN clauses END, sorted according to the ORDER BY clause, and considered according to the aggregation group within the partition.
PARTITION BY column_reference [,...]
The group or groups over which the function operates.
If there is no PARTITION BY or RESET WHEN clauses, then the entire result set, delivered by the FROM clause, constitutes a partition.
PARTITION BY clause is also called the window partition clause.
ORDER BY value_spec [,...]
value_expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
The order in which the values in a group or partition are sorted.
RESET WHEN condition
The group, or groups, over which the function operates, depending on the evaluation of the specified condition. If the condition evaluates to TRUE, a new dynamic partition is created inside the specified window partition.
If there are no RESET WHEN or PARTITION BY clauses, then the entire result set constitutes a single partition.
A conditional expression used to determine conditional partitioning. The condition in the RESET WHEN clause is equivalent in scope to the condition in a QUALIFY clause with the additional constraint that nested ordered analytical functions cannot specify a RESET WHEN clause. In addition, you cannot specify SELECT as a nested subquery within the condition.
The condition is applied to the rows in all designated window partitions to create sub-partitions within the particular window partitions.
For more information, see “RESET WHEN Condition Rules” and the “QUALIFY Clause” in Teradata Vantage™ - SQL Data Manipulation Language, B035-1146.
ASC
That the results are to be ordered in ascending sort order.
If the sort field is a character string, the system orders it in ascending order according to the definition of the collation sequence for the current session.
The default order is ASC.
DESC
That the results are to be ordered in descending sort order.
If the sort field is a character string, the system orders it in descending order according to the definition of the collation sequence for the current session.
NULLS FIRST
NULL results are to be listed first.
NULLS LAST
NULL results are to be listed last.