Builtin

quota

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)
PNOPNAMECOLORWEIGHTCITY
P6CogRed19London

Find the lightest part
quota($P, {WEIGHT}, 1)
PNOPNAMECOLORWEIGHTCITY
P1NutRed12London
P5CamBlue12Paris

Note: there is a tie-break and there are two that are the lightest.