# `bottom`

## Description

The `bottom` command limits the rows returned from a query to the last *N* rows in a given set, ordered by a specified expression. It is useful for finding the lowest-ranking values or least frequent occurrences within a dataset.

Note

When using this command, pay close attention to your ordering expression, as it determines which records are considered "bottom" in the result.

## Syntax

```dataprime
bottom <limit> <result_expression1> [as <alias>] [, <result_expression2> [as
<alias2>], ...] by <orderby_expression> [as <alias>]
```

## Example

**Use case: Get the least active usernames by activity**

We want to identify which users interact with our system the least so we can focus on re-engagement or cleanup efforts.

### Example data

```json
{ "user": "Ariel", ... },
{ "user": "Ariel", ... },
{ "user": "Harel", ... },
{ "user": "Harel", ... },
{ "user": "Dana", ... }
```

### Example query

```dataprime
bottom 10 user by count()
```

### Example output

```json
{ "user": "Dana", "count": 1 },
{ "user": "Harel", "count": 2 },
{ "user": "Ariel", "count": 2 }
```

The command returns the bottom 10 users based on event frequency. In this mock dataset, only three users exist, so all are shown, with "Dana" ranked lowest by activity count.
