GoogleSQL for SecOps supports statistical aggregate functions.
To learn about the syntax for aggregate function calls, see
[Aggregate function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/aggregate-function-calls.md.txt).

## Function list

| Name | Summary |
|---|---|
| [`STDDEV`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#stddev) | An alias of the `STDDEV_SAMP` function. |
| [`STDDEV_POP`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#stddev_pop) | Computes the population (biased) standard deviation of the values. |
| [`STDDEV_SAMP`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#stddev_samp) | Computes the sample (unbiased) standard deviation of the values. |
| [`VAR_POP`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#var_pop) | Computes the population (biased) variance of the values. |
| [`VAR_SAMP`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#var_samp) | Computes the sample (unbiased) variance of the values. |
| [`VARIANCE`](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#variance) | An alias of `VAR_SAMP`. |

## `STDDEV`

```googlesql
STDDEV(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

An alias of [STDDEV_SAMP](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#stddev_samp).

## `STDDEV_POP`

```googlesql
STDDEV_POP(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

Returns the population (biased) standard deviation of the values. The return
result is between `0` and `+Inf`.

All numeric types are supported. If the
input is `NUMERIC` then the internal aggregation is
stable with the final output converted to a `FLOAT64`.
Otherwise the input is converted to a `FLOAT64`
before aggregation, resulting in a potentially unstable result.

This function ignores any `NULL` inputs. If all inputs are ignored, this
function returns `NULL`. If this function receives a single non-`NULL` input,
it returns `0`.

`NaN` is produced if:

- Any input value is `NaN`
- Any input value is positive infinity or negative infinity.

To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/aggregate-function-calls.md.txt).

If this function is used with the `OVER` clause, it's part of a
window function call. In a window function call,
aggregate function clauses can't be used.
To learn more about the `OVER` clause and how to use it, see
[Window function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/window-function-calls.md.txt).

**Return Data Type**

`FLOAT64`

**Examples**

```googlesql
SELECT STDDEV_POP(x) AS results FROM UNNEST([10, 14, 18]) AS x

/*---+
 | results           |
 +---+
 | 3.265986323710904 |
 +---*/
```

```googlesql
SELECT
  x,
  STDDEV_POP(x)
    OVER (
      ORDER BY x
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) AS results
FROM UNNEST([10, 14, 18]) AS x;

/*---+---+
 | x  | results           |
 +---+---+
 | 10 | 0                 |
 | 14 | 2                 |
 | 18 | 3.265986323710904 |
 +---+---*/
```

```googlesql
SELECT STDDEV_POP(x) AS results FROM UNNEST([10, 14, NULL]) AS x

/*---+
 | results |
 +---+
 | 2       |
 +---*/
```

```googlesql
SELECT STDDEV_POP(x) AS results FROM UNNEST([10, NULL]) AS x

/*---+
 | results |
 +---+
 | 0       |
 +---*/
```

```googlesql
SELECT STDDEV_POP(x) AS results FROM UNNEST([NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT STDDEV_POP(x) AS results FROM UNNEST([10, 14, CAST('Infinity' as FLOAT64)]) AS x

/*---+
 | results |
 +---+
 | NaN     |
 +---*/
```

## `STDDEV_SAMP`

```googlesql
STDDEV_SAMP(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

Returns the sample (unbiased) standard deviation of the values. The return
result is between `0` and `+Inf`.

All numeric types are supported. If the
input is `NUMERIC` then the internal aggregation is
stable with the final output converted to a `FLOAT64`.
Otherwise the input is converted to a `FLOAT64`
before aggregation, resulting in a potentially unstable result.

This function ignores any `NULL` inputs. If there are fewer than two non-`NULL`
inputs, this function returns `NULL`.

`NaN` is produced if:

- Any input value is `NaN`
- Any input value is positive infinity or negative infinity.

To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/aggregate-function-calls.md.txt).

If this function is used with the `OVER` clause, it's part of a
window function call. In a window function call,
aggregate function clauses can't be used.
To learn more about the `OVER` clause and how to use it, see
[Window function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/window-function-calls.md.txt).

**Return Data Type**

`FLOAT64`

**Examples**

```googlesql
SELECT STDDEV_SAMP(x) AS results FROM UNNEST([10, 14, 18]) AS x

/*---+
 | results |
 +---+
 | 4       |
 +---*/
```

```googlesql
SELECT
  x,
  STDDEV_SAMP(x)
    OVER (
      ORDER BY x
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) AS results
FROM UNNEST([10, 14, 18]) AS x;

/*---+---+
 | x  | results            |
 +---+---+
 | 10 | NULL               |
 | 14 | 2.8284271247461903 |
 | 18 | 4                  |
 +---+---*/
```

```googlesql
SELECT STDDEV_SAMP(x) AS results FROM UNNEST([10, 14, NULL]) AS x

/*---+
 | results            |
 +---+
 | 2.8284271247461903 |
 +---*/
```

```googlesql
SELECT STDDEV_SAMP(x) AS results FROM UNNEST([10, NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT STDDEV_SAMP(x) AS results FROM UNNEST([NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT STDDEV_SAMP(x) AS results FROM UNNEST([10, 14, CAST('Infinity' as FLOAT64)]) AS x

/*---+
 | results |
 +---+
 | NaN     |
 +---*/
```

## `VAR_POP`

```googlesql
VAR_POP(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

Returns the population (biased) variance of the values. The return result is
between `0` and `+Inf`.

All numeric types are supported. If the
input is `NUMERIC` then the internal aggregation is
stable with the final output converted to a `FLOAT64`.
Otherwise the input is converted to a `FLOAT64`
before aggregation, resulting in a potentially unstable result.

This function ignores any `NULL` inputs. If all inputs are ignored, this
function returns `NULL`. If this function receives a single non-`NULL` input,
it returns `0`.

`NaN` is produced if:

- Any input value is `NaN`
- Any input value is positive infinity or negative infinity.

If this function is used with the `OVER` clause, it's part of a
window function call. In a window function call,
aggregate function clauses can't be used.
To learn more about the `OVER` clause and how to use it, see
[Window function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/window-function-calls.md.txt).

**Return Data Type**

`FLOAT64`

**Examples**

```googlesql
SELECT VAR_POP(x) AS results FROM UNNEST([10, 14, 18]) AS x

/*---+
 | results            |
 +---+
 | 10.666666666666666 |
 +---*/
```

```googlesql
SELECT
  x,
  VAR_POP(x)
    OVER (
      ORDER BY x
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) AS results
FROM UNNEST([10, 14, 18]) AS x;

/*---+---+
 | x  | results            |
 +---+---+
 | 10 | 0                  |
 | 14 | 4                  |
 | 18 | 10.666666666666666 |
 +---+---*/
```

```googlesql
SELECT VAR_POP(x) AS results FROM UNNEST([10, 14, NULL]) AS x

/*---+
 | results |
 +---+
 | 4       |
 +---*/
```

```googlesql
SELECT VAR_POP(x) AS results FROM UNNEST([10, NULL]) AS x

/*---+
 | results |
 +---+
 | 0       |
 +---*/
```

```googlesql
SELECT VAR_POP(x) AS results FROM UNNEST([NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT VAR_POP(x) AS results FROM UNNEST([10, 14, CAST('Infinity' as FLOAT64)]) AS x

/*---+
 | results |
 +---+
 | NaN     |
 +---*/
```

## `VAR_SAMP`

```googlesql
VAR_SAMP(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

Returns the sample (unbiased) variance of the values. The return result is
between `0` and `+Inf`.

All numeric types are supported. If the
input is `NUMERIC` then the internal aggregation is
stable with the final output converted to a `FLOAT64`.
Otherwise the input is converted to a `FLOAT64`
before aggregation, resulting in a potentially unstable result.

This function ignores any `NULL` inputs. If there are fewer than two non-`NULL`
inputs, this function returns `NULL`.

`NaN` is produced if:

- Any input value is `NaN`
- Any input value is positive infinity or negative infinity.

To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/aggregate-function-calls.md.txt).

If this function is used with the `OVER` clause, it's part of a
window function call. In a window function call,
aggregate function clauses can't be used.
To learn more about the `OVER` clause and how to use it, see
[Window function calls](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/window-function-calls.md.txt).

**Return Data Type**

`FLOAT64`

**Examples**

```googlesql
SELECT VAR_SAMP(x) AS results FROM UNNEST([10, 14, 18]) AS x

/*---+
 | results |
 +---+
 | 16      |
 +---*/
```

```googlesql
SELECT
  x,
  VAR_SAMP(x)
    OVER (
      ORDER BY x
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) AS results
FROM UNNEST([10, 14, 18]) AS x;

/*---+---+
 | x  | results |
 +---+---+
 | 10 | NULL    |
 | 14 | 8       |
 | 18 | 16      |
 +---+---*/
```

```googlesql
SELECT VAR_SAMP(x) AS results FROM UNNEST([10, 14, NULL]) AS x

/*---+
 | results |
 +---+
 | 8       |
 +---*/
```

```googlesql
SELECT VAR_SAMP(x) AS results FROM UNNEST([10, NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT VAR_SAMP(x) AS results FROM UNNEST([NULL]) AS x

/*---+
 | results |
 +---+
 | NULL    |
 +---*/
```

```googlesql
SELECT VAR_SAMP(x) AS results FROM UNNEST([10, 14, CAST('Infinity' as FLOAT64)]) AS x

/*---+
 | results |
 +---+
 | NaN     |
 +---*/
```

## `VARIANCE`

```googlesql
VARIANCE(
  [ DISTINCT ]
  expression
)
[ OVER over_clause ]

over_clause:
  { named_window | ( [ window_specification ] ) }

window_specification:
  [ named_window ]
  [ PARTITION BY partition_expression [, ...] ]
  [ ORDER BY expression [ { ASC | DESC }  ] [, ...] ]
  [ window_frame_clause ]

```

**Description**

An alias of [VAR_SAMP](https://docs.cloud.google.com/chronicle/docs/reference/standard-sql/statistical_aggregate_functions.md.txt#var_samp).