quota(a, {sort_attr_list}, limit)
Returns a copy of relation a capped to the limit number after sorting by and matching sort_attr_list.
Use -attr to reverse the sort.
In the case of tie-breaks or lack of data, the number of tuples returned may not match the limit exactly.
Examples
Find the heaviest part
quota($P, {-WEIGHT}, 1)
| PNO | PNAME | COLOR | WEIGHT | CITY |
|---|---|---|---|---|
| P6 | Cog | Red | 19 | London |
Find the lightest part
quota($P, {WEIGHT}, 1)
| PNO | PNAME | COLOR | WEIGHT | CITY |
|---|---|---|---|---|
| P1 | Nut | Red | 12 | London |
| P5 | Cam | Blue | 12 | Paris |
Note: there is a tie-break and there are two that are the lightest.