A table expression where the RANK is computed. If omitted, OrderBy must be explicitly specified.
OrderBy
Optional
Columns that define how each partition is sorted. If omitted, Relation must be explicitly specified.
Blanks
Optional
Defines how to handle BLANK OrderBy values. Valid values include: DEFAULT, FIRST, LAST.
PartitionBy
Optional
Columns that define how Relation is partitioned.
MatchBy
Optional
Columns that define how the current row is identified.
Reset
Optional
Specifies how the calculation restarts. Valid values are: None, LowestParent, HighestParent, or an integer.
Return Values
The rownumber number for the current context.
Remarks
Each orderBy, partitionBy, and matchBy column must have a corresponding outer value to help define the current row on which to operate, with the following behavior:
If there is exactly one corresponding outer column, its value is used.
If there is no corresponding outer column, then:
ROWNUMBER will first determine all orderBy, partitionBy, and matchBy columns that have no corresponding outer column.
For every combination of existing values for these columns in ROWNUMBER parent context, ROWNUMBER is evaluated and a row is returned.
ROWNUMBER’s final output is a union of these rows.
If there is more than one corresponding outer column, an error is returned.
If matchBy is present, then ROWNUMBER will try to use columns in matchBy and partitionBy to idenfity the current row.
If the columns specified within orderBy and partitionBy cannot uniquely identify every row in relation, then:
ROWNUMBER will try to find the least number of additional columns required to uniquely identify every row.
If such columns can be found, ROWNUMBER will
Try to find the least number of additional columns required to uniquely identify every row.
Automatically append these new columns to orderBy clause.
Sort each partition using this new set of orderBy columns.
If such columns cannot be found and the function detects a tie at runtime, an error is returned.
reset can be used in visual calculations only, and cannot be used in combination with orderBy or partitionBy. If reset is present, axis can be specified but relation cannot.