> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-dx-3081-agentkit-tanstack-ai-backends.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# $stats

`$stats` returns multiple basic metrics in one pass.

For the selected field, it computes:

* `count`
* `sum`
* `min`
* `max`
* `avg`

This is equivalent to running `$count`, `$sum`, `$min`, `$max`, and `$avg` together, but returned as a single object.

### Compatibility

| Field Type | Supported |
| - | - |
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | Yes |
| KEYWORD | No |
| FACET | No |

Field must be `FAST`.

### Arguments

| Argument | Type | Required | Description |
| - | - | - | - |
| `field` | `string` | Yes | Field to aggregate. |
| `missing` | `number` | No | Fallback value for missing fields. |

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    await index.aggregate({
      aggregations: {
        price_stats: { $stats: { field: "price", missing: 0 } },
      },
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    index.aggregate(
        aggregations={"price_stats": {"$stats": {"field": "price", "missing": 0}}}
    )
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={null}
    SEARCH.AGGREGATE products '{}' '{"price_stats": {"$stats": {"field": "price", "missing": 0}}}'
    ```
  </Tab>
</Tabs>

### Output

```json theme={null}
{ "price_stats": { "count": 9, "min": 0, "max": 80, "sum": 360, "avg": 40 } }
```

`min`, `max`, and `avg` can be `null` when no values are available.


## Related topics

- [FUNCTION STATS](/redis/commands/functions/function-stats.md)
- [$extendedStats](/redis/search/aggregation-operators/metric-aggregations/extended-stats.md)
- [Get Database Stats](/devops/developer-api/redis/get_database_stats.md)
- [Get Index Stats](/api-reference/vector/get-index-stats.md)
