---
title: tuple_sketch_summary_double function
description: Learn the syntax of the tuple\_sketch\_summary\_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_sketch_summary_double
---

# `tuple_sketch_summary_double` function

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

Aggregates the summary values from a TupleSketch with double summaries according to the specified mode.

## Syntax

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

## Arguments

* **sketch**: 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 `DOUBLE` value representing the aggregated summary across all keys in the sketch.

## Notes

* In `'sum'` mode, the function returns the sum of all summary values.
* In `'min'` mode, the function returns the minimum summary value.
* In `'max'` mode, the function returns the maximum summary value.
* In `'alwaysone'` mode, the function returns the count of entries (equivalent to distinct count).

## Common error conditions

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

## Examples

```sql
-- Sum of all summary values
> SELECT tuple_sketch_summary_double(tuple_sketch_agg_double(key, summary)) FROM VALUES (1, 1.0D), (1, 2.0D), (2, 3.0D) tab(key, summary);
6.0
```

## Related

* [`tuple_sketch_summary_integer` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_sketch_summary_integer.md)
* [`tuple_sketch_estimate_double` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/tuple_sketch_estimate_double.md)
