rank(operand: Relation, order: Ordering, as: AttrName) -> Relation
rank(suppliers, [:status], :ranking)
rank(suppliers, [:status, :sid], :ranking)
Extends tuples from
operand with a new attribute (
as) capturing the
tuple position with respect to
The ranking of a tuple
t is more precisely defined as the number of tuples
operand that would come strictly before
t if they were all ordered
order. 'Equal' tuples with respect to
order are not counted
in this ranking.
This means that, unless
order is a total order, duplicate ranking may be
observed. In contrast, if
order covers a candidate key then the ranking
as) is unique, and therefore defines an additional candidate
key for the resulting relation.
Note that this operator does not compile to SQL so far. The
frame operators provide useful alternatives when the aim is to compute
a subset of tuples based on a ranking.