> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/aggregation/covar-samp",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for COVAR_SAMP

# COVAR_SAMP

Computes the sample covariance between two numeric expressions. If either one of expressions is `NULL` - that input row is ignored.
Use this when analyzing a sample rather than an entire population. For covariance of population see [COVAR\_POP](/reference-sql/functions-reference/aggregation/covar-pop).

## Covariance vs Correlation

**Covariance** and **correlation** both describe how two variables change together, but they do so in different ways:

* **Covariance** measures the **direction** of the relationship between two variables:
  * Positive covariance: variables tend to increase together.
  * Negative covariance: one increases as the other decreases.
  * Its value is **unbounded** and depends on the units of the variables, making it hard to interpret on its own.

* **Correlation**, specifically **Pearson correlation**, standardizes the relationship:
  * It is the **normalized version of covariance**, giving a unitless measure between **-1 and 1**.
  * This makes it easier to compare the strength of relationships between different pairs of variables.

For information on correlation see [CORR](/reference-sql/functions-reference/aggregation/corr)

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
COVAR_SAMP(<expr1>, <expr2>) [FILTER ([WHERE] <condition>)]
```

## Parameters

| Parameter     | Description                                                       | Supported input types |
| :------------ | :---------------------------------------------------------------- | :-------------------- |
| `<expr1>`     | First numeric expression to use for covariance computation.       | `DOUBLE PRECISION`    |
| `<expr2>`     | Second numeric expression to use for covariance computation.      | `DOUBLE PRECISION`    |
| `<condition>` | An optional boolean expression to filter rows used in aggregation | `BOOL`                |

## Return Type

`COVAR_SAMP` returns a result of type `DOUBLE PRECISION`.

## Example

## Examples

The code examples use `PlayStats` table from the sample `UltraFast` database.

**Example**

The `CurrentLevel` and `CurrentScore` variables are highly correlated

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT COVAR_SAMP(CurrentScore, CurrentLevel) FROM PlayStats
```

**Returns**

`473291.6614849927`

**Example**

But `CurrentLevel` and `CurrentScore` variables are not correlated at all

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT COVAR_SAMP(CurrentLevel, CurrentSpeed) FROM PlayStats
```

**Returns**

`0.040317002824098884`
