# top

relationalai.semantics.std.aggregates

```python
top(limit: int, *args: AggValue) -> Aggregate
```

Get the top N results in descending order.

## Parameters

- `limit` (`int`) - Number of top results to return.
- `*args` (`AggValue`, default: `()`) - Values to order by (descending).

## Returns

- `Aggregate` - An `Aggregate` representing the computation of the top N results.

## Examples

Get top 10 highest-paid employees:

```python
select(Employee).where(aggregates.top(10, Employee.salary))
```

Get top 3 products by revenue per store:

```python
select(Product).where(
    aggregates.top(3, Product.revenue).per(Store).where(Product.store == Store)
)
```

## Referenced By

1. [RelationalAI Documentation](/index.md)1) [Build With RelationalAI](/build/index.md)1. [Use advanced reasoning](/build/reasoning/index.md) / [Rules-based reasoning](/build/reasoning/rules-based/index.md)1) [Aggregate and group data](/build/reasoning/rules-based/aggregate-and-group-data/index.md)1. [Pick top and bottom results](/build/reasoning/rules-based/aggregate-and-group-data/index.md#pick-top-and-bottom-results)
   2) [Interact with RelationalAI](/interact/index.md)1) [Query a model with PyRel](/interact/query-a-model-with-pyrel/index.md)1. [Rank and select top results with `rank`, `asc`, `desc`, and `top`](/interact/query-a-model-with-pyrel/index.md#rank-and-select-top-results-with-rank-asc-desc-and-top)
