---
title: tuple_intersection_agg_double aggregate function
description: Learn the syntax of the tuple\_intersection\_agg\_double aggregate function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_agg_double
---

# `tuple_intersection_agg_double` aggregate function

**Applies to:** ![check marked yes](https://docs.databricks.com/gcp/en/images/icons/check.png) Databricks Runtime 18.1 and above

Computes the intersection of multiple TupleSketch binary representations with double summaries. Returns a sketch containing only keys common to all input sketches.

## Syntax

```
tuple_intersection_agg_double ( sketch [, mode ] )
```

## Arguments

* **sketch**: A TupleSketch in binary format with double summaries (such as from [tuple\_sketch\_agg\_double](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_sketch_agg_double.md)).
* **mode**: An optional `STRING` literal specifying the aggregation mode for combining duplicate key summaries. Valid values: `'sum'`, `'min'`, `'max'`, `'alwaysone'`. The default is `'sum'`.

## Returns

A `BINARY` value containing the intersected TupleSketch with double summaries.

## Notes

* `NULL` input sketches are ignored during aggregation.
* The result contains only keys that appear in all input sketches.
* For intersecting exactly two sketches, use the scalar [tuple\_intersection\_double](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_double.md) function.

## Common error conditions

* [TUPLE\_INVALID\_INPUT\_SKETCH\_BUFFER](https://docs.databricks.com/gcp/en/error-messages/error-classes.md#tuple_invalid_input_sketch_buffer)

## Examples

```sql
-- Find keys common to all sketches
> SELECT tuple_sketch_estimate_double(tuple_intersection_agg_double(sketch)) FROM (
    SELECT tuple_sketch_agg_double(key, summary) as sketch FROM VALUES (1, 5.0D), (2, 10.0D), (3, 15.0D) tab(key, summary)
    UNION ALL
    SELECT tuple_sketch_agg_double(key, summary) as sketch FROM VALUES (2, 3.0D), (3, 7.0D), (4, 12.0D) tab(key, summary)
  );
2.0
```

## Related

* [`tuple_intersection_agg_integer` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_agg_integer.md)
* [`tuple_intersection_double` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_double.md)
* [`tuple_sketch_agg_double` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_sketch_agg_double.md)
