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

> Reference material for HASH_AGG

# HASH_AGG

Calculates a hash value over all rows on a list of arguments. When `*` is specified as an argument - calculates a hash aggregation over all columns in the input. Performing a hash aggregation operation is useful for warming up table data or to check if the same values exist in two different tables.

**Alias:** `CHECKSUM`

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
HASH_AGG( <expression1> [, <expression2>] [, <expression3>] [, ...<expressionN>] ) [FILTER ([WHERE] <condition>)]
HASH_AGG(*) [FILTER ([WHERE] <condition>)]
```

## Parameters

| Parameter      | Description                                                                     | Supported input types |
| :------------- | :------------------------------------------------------------------------------ | :-------------------- |
| `<expression>` | A column name for specific results for the `HASH_AGG` function to be applied to | Any `<column>` name   |
| `<condition>`  | An optional boolean expression to filter rows used in aggregation               | `BOOL`                |

## Return Type

`BIGINT`

## Examples

The following examples use a `tournament_information` table:

<div className="query-window">
  ```
  SELECT name, prizedollars, tournamentid
  FROM (VALUES
      ('The Snow Park Grand Prix', 20903.0, 1),
      ('The Acceleration Championship', 19274.0, 2),
      ('The Acceleration Trials', 13877.0, 3)
  ) AS tournament_information(name, prizedollars, tournamentid);
  ```

  | name <span>text</span>        | prizedollars <span>double</span> | tournamentid <span>int</span> |
  | :---------------------------- | :------------------------------- | :---------------------------- |
  | The Snow Park Grand Prix      | 20903                            | 1                             |
  | The Acceleration Championship | 19274                            | 2                             |
  | The Acceleration Trials       | 13877                            | 3                             |

  <p><span>Rows: 3</span><span>Execution time: 43.36ms</span></p>
</div>

The following example calculates a hash aggregation over all columns of a tournament table:

<div className="query-window">
  ```
  SELECT HASH_AGG(*) FROM (VALUES
      ('The Snow Park Grand Prix', 20903.0, 1),
      ('The Acceleration Championship', 19274.0, 2),
      ('The Acceleration Trials', 13877.0, 3)
  ) AS tournament_information(name, prizedollars, tournamentid);
  ```

  | hash\_agg <span>long</span> |
  | :-------------------------- |
  | 7652934541320494802         |

  <p><span>Rows: 1</span><span>Execution time: 6.94ms</span></p>
</div>

The following example calculates a hash aggregation over `prizedollars` and `tournamentid` only:

<div className="query-window">
  ```
  SELECT HASH_AGG(prizedollars, tournamentid) FROM (VALUES
      ('The Snow Park Grand Prix', 20903.0, 1),
      ('The Acceleration Championship', 19274.0, 2),
      ('The Acceleration Trials', 13877.0, 3)
  ) AS tournament_information(name, prizedollars, tournamentid);
  ```

  | hash\_agg <span>long</span> |
  | :-------------------------- |
  | 3058600455882068351         |

  <p><span>Rows: 1</span><span>Execution time: 6.64ms</span></p>
</div>
