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

# ds_theta_intersect

> Returns a serialized Theta sketch whose distinct count estimates |A∩B|, the intersection of two input sketches.

Scalar pairwise intersection of two serialized Apache DataSketches Theta sketches.
Returns a single serialized compact sketch whose distinct count estimates
`|A ∩ B|`. Returns `NULL` if either input is `NULL`.

Unlike HyperLogLog sketches, theta sketches preserve enough state to support
intersection, which is what makes this operation possible without storing the
underlying values.

## Syntax

```Haskell theme={null}
VARBINARY ds_theta_intersect(sketch_a, sketch_b)
```

* `sketch_a`, `sketch_b`: `VARBINARY` compact theta sketches.

## Examples

```SQL theme={null}
-- Distinct users who appeared in both cohort A and cohort B.
SELECT ds_theta_estimate(ds_theta_intersect(a.sk, b.sk))
FROM cohort_a a JOIN cohort_b b USING (day);
```

## Keywords

DS\_THETA\_INTERSECT, DS\_THETA\_UNION, DS\_THETA\_A\_NOT\_B


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.