---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/function-ref/COMPARE
  - ru/function-ref/COMPARE
  - href: en/function-ref/COMPARE.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/function-ref/COMPARE.html
editable: false
vcsPath: en/function-ref/COMPARE.md
---

# COMPARE



#### Syntax {#syntax}


```
COMPARE( left, right, epsilon )
```

#### Description {#description}
Returns:
* 0 if `left` and `right` differs by not more than `epsilon`.
* -1 if `left` is less than `right` by more than `epsilon`.
* 1 if `left` is greater than `right` by more than `epsilon`.

**Argument types:**
- `left` — `Fractional number | Integer`
- `right` — `Fractional number | Integer`
- `epsilon` — `Fractional number | Integer`


**Return type**: `Integer`

#### Examples {#examples}

```
COMPARE(1.25, 1.26, 0.1) = 0
```

```
COMPARE(1.25, 1.26, 0.001) = -1
```

```
COMPARE(1.26, 1.25, 0.001) = 1
```


#### Data source support {#data-source-support}

`ClickHouse 21.8`, `Files`, `Google Sheets`, `Yandex Documents`.
