tag(a, {tag_within_list}, tag_name)
A relation operator.
Adds a new attr, named tag_name, with an incrementing sequence, from 0, within each tag_within_list.
If {} is used for the tag_with_list, a unique tag per tuple is given.
Use -attr to reverse the tag within order. You should end with a unique attr for stability in case of tie-breaks.
Examples
tag
tag($S, {STATUS, SNO}, status_seq)
| SNO | SNAME | STATUS | CITY | status_seq |
|---|---|---|---|---|
| S1 | Smith | 20 | London | 0 |
| S2 | Jones | 10 | Paris | 0 |
| S3 | Blake | 30 | Paris | 0 |
| S4 | Clark | 20 | London | 1 |
| S5 | Adams | 30 | Athens | 1 |
tag unique
tag($S, {}, seq)
| SNO | SNAME | STATUS | CITY | seq |
|---|---|---|---|---|
| S1 | Smith | 20 | London | 0 |
| S2 | Jones | 10 | Paris | 1 |
| S3 | Blake | 30 | Paris | 2 |
| S4 | Clark | 20 | London | 3 |
| S5 | Adams | 30 | Athens | 4 |