limit
relationalai.semantics.std.aggregates
limit(limit: int, *args: AggValue | Ordering) -> AggregateLimit results based on ordering.
Parameters
Section titled “Parameters”
(limitint) - Maximum number of results to return.
(*argsAggValue|Ordering, default:()) - Values or Ordering specifications to order by.
Returns
Section titled “Returns”Aggregate- AnAggregaterepresenting the computation of the limited results.
Examples
Section titled “Examples”Get top 5 employees by salary:
>>> select(Employee).where(aggregates.limit(5, aggregates.desc(Employee.salary)))Get top 3 products by sales per category:
>>> select(Product).where(aggregates.limit(3, aggregates.desc(Product.sales)).per(Category).where(Product.category == Category))