Sha256: 9b82ae585edfdf4bbcaaae4c90c009e546a48d8baf9df67d5fce71388578221e

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# Rank

Tuple ranking

## Signature

rank(operand: Relation, order: Ordering, as: AttrName) -> Relation

## Examples

rank(suppliers, [:status], :ranking)

rank(suppliers, [:status, :sid], :ranking)

## Description

Extends tuples from `operand` with a new attribute (`as`) capturing the
tuple position with respect to `order`.

The ranking of a tuple `t` is more precisely defined as the number of tuples
from `operand` that would come strictly before `t` if they were all ordered
according to `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
attribute (`as`) is unique, and therefore defines an additional candidate
key for the resulting relation.

## Implementation notes

Note that this operator does not compile to SQL so far. The `page` and
`frame` operators provide useful alternatives when the aim is to compute
a subset of tuples based on a ranking.

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alf-shell-0.16.4 doc/txt/rank.txt
alf-shell-0.16.3 doc/txt/rank.txt
alf-shell-0.16.2 doc/txt/rank.txt
alf-shell-0.16.1 doc/txt/rank.txt
alf-shell-0.16.0 doc/txt/rank.txt
alf-shell-0.15.0 doc/txt/rank.txt