> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# approx_count()

> Estimate the number of times a value appears from a `CountMinSketch`

<Icon icon="flask" /> Early access <Icon icon="tag" iconType="duotone" /> Since [1.8.0][toolkit-1.8.0]

Estimate the number of times a given text value appears in a column.

## Samples

Given a table of stock data, estimate how many times the symbol `AAPL` appears:

```sql theme={"dark"}
WITH t AS (
  SELECT toolkit_experimental.count_min_sketch(symbol, 0.01, 0.01) AS symbol_sketch
  FROM crypto_ticks
)
SELECT toolkit_experimental.approx_count('AAPL', symbol_sketch)
FROM t;
```

## Arguments

The syntax is:

```sql theme={"dark"}
approx_count (
    item TEXT,
    agg CountMinSketch
) RETURNS BIGINT
```

| Name   | Type           | Default | Required | Description                                                                    |
| ------ | -------------- | ------- | -------- | ------------------------------------------------------------------------------ |
| `item` | TEXT           | -       | ✔        | The value you want to estimate occurrences of                                  |
| `agg`  | CountMinSketch | -       | ✔        | A `CountMinSketch` object created using [`count_min_sketch`][count-min-sketch] |

## Returns

| Column        | Type   | Description                                                 |
| ------------- | ------ | ----------------------------------------------------------- |
| approx\_count | BIGINT | The estimated number of times `item` appeared in the sketch |

[count-min-sketch]: /api-reference/timescaledb-toolkit/frequency-analysis/count_min_sketch/count_min_sketch

[toolkit-1.8.0]: https://github.com/timescale/timescaledb-toolkit/releases/tag/1.8.0
