> ## 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 VECTOR_SQUARED_EUCLIDEAN_DISTANCE function

# VECTOR_SQUARED_EUCLIDEAN_DISTANCE

## VECTOR\_SQUARED\_EUCLIDEAN\_DISTANCE

Returns the squared [Euclidean distance](/reference-sql/functions-reference/vector/vector-euclidean-distance), or squared [L2 distance](/reference-sql/functions-reference/vector/vector-euclidean-distance) between two vectors. The squared Euclidean distance measures how far apart two vectors based on the size of their differences, without considering direction. By squaring the difference, it emphasizes larger differences, which can help in finding outliers or large deviations.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
VECTOR_SQUARED_EUCLIDEAN_DISTANCE(<array>, <array>)
```

## Parameters

| Parameter | Description                                        | Supported input types                                                 |
| :-------- | :------------------------------------------------- | :-------------------------------------------------------------------- |
| `<array>` | The first array used in the distance calculation.  | Any array of [numeric data types](/reference-sql/data-types#numeric). |
| `<array>` | The second array used in the distance calculation. | Any array of [numeric data types](/reference-sql/data-types#numeric). |

## Notes

Both input `array` arguments must have the same number of elements.

## Return Type

`DOUBLE`

## Examples

**Example**

The following code returns the squared Euclidean distance between two vectors:

<div className="query-window">
  ```
  SELECT VECTOR_SQUARED_EUCLIDEAN_DISTANCE([1, 2], [3, 4]) AS distance;
  ```

  | distance <span>double</span> |
  | :--------------------------- |
  | 8                            |

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

**Example**

The following code returns the squared Euclidean distance between two identical vectors:

<div className="query-window">
  ```
  SELECT VECTOR_SQUARED_EUCLIDEAN_DISTANCE([1, 1], [1, 1]) AS distance;
  ```

  | distance <span>double</span> |
  | :--------------------------- |
  | 0                            |

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

**Example**

The following code returns the squared Euclidean distance between two vectors that are very far apart:

<div className="query-window">
  ```
  SELECT VECTOR_SQUARED_EUCLIDEAN_DISTANCE([1, 1], [10, 10]) AS distance;
  ```

  | distance <span>double</span> |
  | :--------------------------- |
  | 162                          |

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