Other functions

**Examples**

**minSampleSizeContinuous**

```
SELECT minSampleSizeContinuous(112.25, 21.1, 0.03, 0.80, 0.05) AS sample_size
```

```
(616.2931945826209,108.8825,115.6175)
```

## minSampleSizeConversion[​](#minSampleSizeConversion "Direct link to minSampleSizeConversion")

Introduced in: v22.6.0

Calculates minimum required sample size for an A/B test comparing conversions (proportions) in two samples.

Uses the formula described in [this article](https://towardsdatascience.com/required-sample-size-for-a-b-testing-6f6608dd330a). Assumes equal sizes of treatment and control groups. Returns the sample size required for one group (i.e. the sample size required for the whole experiment is twice the returned value).

**Syntax**

```
minSampleSizeConversion(baseline, mde, power, alpha)
```

**Arguments**

- `baseline` — Baseline conversion. [`Float*`](/docs/sql-reference/data-types/float)
- `mde` — Minimum detectable effect (MDE) as percentage points (e.g. for a baseline conversion 0.25 the MDE 0.03 means an expected change to 0.25 ± 0.03). [`Float*`](/docs/sql-reference/data-types/float)
- `power` — Required statistical power of a test (1 - probability of Type II error). [`Float*`](/docs/sql-reference/data-types/float)
- `alpha` — Required significance level of a test (probability of Type I error). [`Float*`](/docs/sql-reference/data-types/float)

**Returned value**

Returns a named Tuple with 3 elements: `minimum_sample_size`, `detect_range_lower`, `detect_range_upper`. These are, respectively: the required sample size, the lower bound of the range of values not detectable with the returned required sample size, calculated as `baseline - mde`, the upper bound of the range of values not detectable with the returned required sample size, calculated as `baseline + mde`. [`Tuple(Float64, Float64, Float64)`](/docs/sql-reference/data-types/tuple)

**Examples**

**minSampleSizeConversion**

```
SELECT minSampleSizeConversion(0.25, 0.03, 0.80, 0.05) AS sample_size
```

```
(3396.077603219163,0.22,0.28)
```

## neighbor[​](#neighbor "Direct link to neighbor")

Introduced in: v20.1.0

Returns a value from a column at a specified offset from the current row.
This function is deprecated and error-prone because it operates on the physical order of data blocks which may not correspond to the logical order expected by users.
Consider using proper window functions instead.

The function can be enabled by setting `allow_deprecated_error_prone_window_functions = 1`.

**Syntax**

```
neighbor(column, offset[, default_value])
```

**Arguments**

- `column` — The source column. [`Any`](/docs/sql-reference/data-types)
- `offset` — The offset from the current row. Positive values look forward, negative values look backward. [`Integer`](/docs/sql-reference/data-types/int-uint)
- `default_value` — Optional. The value to return if the offset goes beyond the data bounds. If not specified, uses the default value for the column type. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a value from the specified offset, or default if out of bounds. [`Any`](/docs/sql-reference/data-types)

**Examples**

**Usage example**

```
SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10;
```

```
┌─number─┬─neighbor(number, 2)─┐
│      0 │                   2 │
│      1 │                   3 │
│      2 │                   4 │
│      3 │                   5 │
│      4 │                   6 │
│      5 │                   7 │
│      6 │                   8 │
│      7 │                   9 │
│      8 │                   0 │
│      9 │                   0 │
└────────┴─────────────────────┘
```

**With default value**

```
SELECT number, neighbor(number, 2, 999) FROM system.numbers LIMIT 10;
```

```
┌─number─┬─neighbor(number, 2, 999)─┐
│      0 │                        2 │
│      1 │                        3 │
│      2 │                        4 │
│      3 │                        5 │
│      4 │                        6 │
│      5 │                        7 │
│      6 │                        8 │
│      7 │                        9 │
│      8 │                      999 │
│      9 │                      999 │
└────────┴──────────────────────────┘
```

## normalizeQuery[​](#normalizeQuery "Direct link to normalizeQuery")

Introduced in: v20.8.0

Replaces literals, sequences of literals and complex aliases (containing whitespace, more than two digits or at least 36 bytes long such as UUIDs) with placeholder `?`.

**Syntax**

```
normalizeQuery(x)
```

**Arguments**

- `x` — Sequence of characters. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the given sequence of characters with placeholders. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT normalizeQuery('[1, 2, 3, x]') AS query
```

```
┌─query────┐
│ [?.., x] │
└──────────┘
```

## normalizeQueryKeepNames[​](#normalizeQueryKeepNames "Direct link to normalizeQueryKeepNames")

Introduced in: v21.2.0

Replaces literals and sequences of literals with placeholder `?` but does not replace complex aliases (containing whitespace, more than two digits or at least 36 bytes long such as UUIDs).
This helps better analyze complex query logs.

**Syntax**

```
normalizeQueryKeepNames(x)
```

**Arguments**

- `x` — Sequence of characters. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the given sequence of characters with placeholders. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT normalizeQuery('SELECT 1 AS aComplexName123'), normalizeQueryKeepNames('SELECT 1 AS aComplexName123')
```

```
┌─normalizeQuery('SELECT 1 AS aComplexName123')─┬─normalizeQueryKeepNames('SELECT 1 AS aComplexName123')─┐
│ SELECT ? AS `?`                               │ SELECT ? AS aComplexName123                            │
└───────────────────────────────────────────────┴────────────────────────────────────────────────────────┘
```

## normalizedQueryHash[​](#normalizedQueryHash "Direct link to normalizedQueryHash")

Introduced in: v20.8.0

Returns identical 64 bit hash values without the values of literals for similar queries.
Can be helpful in analyzing query logs.

**Syntax**

```
normalizedQueryHash(x)
```

**Arguments**

- `x` — Sequence of characters. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a 64 bit hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT normalizedQueryHash('SELECT 1 AS `xyz`') != normalizedQueryHash('SELECT 1 AS `abc`') AS res
```

```
┌─res─┐
│   1 │
└─────┘
```

## normalizedQueryHashKeepNames[​](#normalizedQueryHashKeepNames "Direct link to normalizedQueryHashKeepNames")

Introduced in: v21.2.0

Like [`normalizedQueryHash`](#normalizedQueryHash) it returns identical 64 bit hash values without the values of literals for similar queries, but it does not replace complex aliases (containing whitespace, more than two digits or at least 36 bytes long such as UUIDs) with a placeholder before hashing.
Can be helpful in analyzing query logs.

**Syntax**

```
normalizedQueryHashKeepNames(x)
```

**Arguments**

- `x` — Sequence of characters. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a 64 bit hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT normalizedQueryHash('SELECT 1 AS `xyz123`') != normalizedQueryHash('SELECT 1 AS `abc123`') AS normalizedQueryHash;
SELECT normalizedQueryHashKeepNames('SELECT 1 AS `xyz123`') != normalizedQueryHashKeepNames('SELECT 1 AS `abc123`') AS normalizedQueryHashKeepNames;
```

```
┌─normalizedQueryHash─┐
│                   0 │
└─────────────────────┘
┌─normalizedQueryHashKeepNames─┐
│                            1 │
└──────────────────────────────┘
```

## parseReadableSize[​](#parseReadableSize "Direct link to parseReadableSize")

Introduced in: v24.6.0