---
title: tuple_intersection_double function
description: Learn the syntax of the tuple\_intersection\_double 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_double
---

# `tuple_intersection_double` function

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

Computes the set intersection of exactly two TupleSketch binary representations with double summaries.

## Syntax

```
tuple_intersection_double ( first, second [, mode ] )
```

## Arguments

* **first**: A TupleSketch in binary format with double summaries.
* **second**: A TupleSketch in binary format with double summaries.
* **mode**: An optional `STRING` literal specifying the aggregation mode. Valid values: `'sum'`, `'min'`, `'max'`, `'alwaysone'`. The default is `'sum'`.

## Returns

A `BINARY` value containing the TupleSketch representing the intersection.

## Notes

* The result contains only keys that appear in both input sketches.
* For intersecting more than two sketches, use [tuple\_intersection\_agg\_double](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_agg_double.md).

## 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
> SELECT tuple_sketch_estimate_double(
    tuple_intersection_double(
      tuple_sketch_agg_double(col1, val1),
      tuple_sketch_agg_double(col2, val2)
    )
  ) FROM VALUES (1, 1.0D, 1, 4.0D), (2, 2.0D, 2, 5.0D), (3, 3.0D, 4, 6.0D) tab(col1, val1, col2, val2);
2.0
```

## Related

* [`tuple_intersection_integer` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_integer.md)
* [`tuple_intersection_theta_double` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_theta_double.md)
* [`tuple_intersection_agg_double` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_intersection_agg_double.md)
