diff --git a/docs/en/sql-reference/aggregate-functions/reference/greatest.md b/docs/en/sql-reference/aggregate-functions/reference/greatest.md deleted file mode 100644 index d5efea44790..00000000000 --- a/docs/en/sql-reference/aggregate-functions/reference/greatest.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -slug: /en/sql-reference/aggregate-functions/reference/greatest -title: greatest ---- - -Aggregate function that returns the greatest across a list of values. All of the list members must be of comparable types. - -Examples: - -```sql -SELECT - toTypeName(greatest(toUInt8(1), 2, toUInt8(3), 3.)), - greatest(1, 2, toUInt8(3), 3.) -``` -```response -┌─toTypeName(greatest(toUInt8(1), 2, toUInt8(3), 3.))─┬─greatest(1, 2, toUInt8(3), 3.)─┐ -│ Float64 │ 3 │ -└─────────────────────────────────────────────────────┴────────────────────────────────┘ -``` - -:::note -The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. -::: - -```sql -SELECT greatest(['hello'], ['there'], ['world']) -``` -```response -┌─greatest(['hello'], ['there'], ['world'])─┐ -│ ['world'] │ -└───────────────────────────────────────────┘ -``` - -```sql -SELECT greatest(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) -``` -```response -┌─greatest(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ -│ 2023-05-12 01:16:59.000 │ -└──---──────────────────────────────────────────────────────────────────────────┘ -``` - -:::note -The type returned is a DateTime64 as the DataTime32 must be promoted to 64 bit for the comparison. -::: - -Also see [least](/docs/en/sql-reference/aggregate-functions/reference/least.md). - diff --git a/docs/en/sql-reference/aggregate-functions/reference/least.md b/docs/en/sql-reference/aggregate-functions/reference/least.md deleted file mode 100644 index ae4b1d43182..00000000000 --- a/docs/en/sql-reference/aggregate-functions/reference/least.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -slug: /en/sql-reference/aggregate-functions/reference/least -title: least ---- - -Aggregate function that returns the least across a list of values. All of the list members must be of comparable types. - -Examples: - -```sql -SELECT - toTypeName(least(toUInt8(1), 2, toUInt8(3), 3.)), - least(1, 2, toUInt8(3), 3.) -``` -```response -┌─toTypeName(least(toUInt8(1), 2, toUInt8(3), 3.))─┬─least(1, 2, toUInt8(3), 3.)─┐ -│ Float64 │ 1 │ -└──────────────────────────────────────────────────┴─────────────────────────────┘ -``` - -:::note -The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. -::: - -```sql -SELECT least(['hello'], ['there'], ['world']) -``` -```response -┌─least(['hello'], ['there'], ['world'])─┐ -│ ['hello'] │ -└────────────────────────────────────────┘ -``` - -```sql -SELECT least(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) -``` -```response -┌─least(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ -│ 2023-05-12 01:16:59.000 │ -└────────────────────────────────────────────────────────────────────────────┘ -``` - -:::note -The type returned is a DateTime64 as the DataTime32 must be promoted to 64 bit for the comparison. -::: - -Also see [greatest](/docs/en/sql-reference/aggregate-functions/reference/greatest.md). - diff --git a/docs/en/sql-reference/functions/conditional-functions.md b/docs/en/sql-reference/functions/conditional-functions.md index eb86a6e551a..eb4e98961f1 100644 --- a/docs/en/sql-reference/functions/conditional-functions.md +++ b/docs/en/sql-reference/functions/conditional-functions.md @@ -152,3 +152,85 @@ FROM LEFT_RIGHT │ 4 │ ᴺᵁᴸᴸ │ Both equal │ └──────┴───────┴──────────────────┘ ``` + +## greatest + +Returns the greatest across a list of values. All of the list members must be of comparable types. + +Examples: + +```sql +SELECT greatest(1, 2, toUInt8(3), 3.) result, toTypeName(result) type; +``` +```response +┌─result─┬─type────┐ +│ 3 │ Float64 │ +└────────┴─────────┘ +``` + +:::note +The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. +::: + +```sql +SELECT greatest(['hello'], ['there'], ['world']) +``` +```response +┌─greatest(['hello'], ['there'], ['world'])─┐ +│ ['world'] │ +└───────────────────────────────────────────┘ +``` + +```sql +SELECT greatest(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) +``` +```response +┌─greatest(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ +│ 2023-05-12 01:16:59.000 │ +└──---──────────────────────────────────────────────────────────────────────────┘ +``` + +:::note +The type returned is a DateTime64 as the DataTime32 must be promoted to 64 bit for the comparison. +::: + +## least + +Returns the least across a list of values. All of the list members must be of comparable types. + +Examples: + +```sql +SELECT least(1, 2, toUInt8(3), 3.) result, toTypeName(result) type; +``` +```response +┌─result─┬─type────┐ +│ 1 │ Float64 │ +└────────┴─────────┘ +``` + +:::note +The type returned is a Float64 as the UInt8 must be promoted to 64 bit for the comparison. +::: + +```sql +SELECT least(['hello'], ['there'], ['world']) +``` +```response +┌─least(['hello'], ['there'], ['world'])─┐ +│ ['hello'] │ +└────────────────────────────────────────┘ +``` + +```sql +SELECT least(toDateTime32(now() + toIntervalDay(1)), toDateTime64(now(), 3)) +``` +```response +┌─least(toDateTime32(plus(now(), toIntervalDay(1))), toDateTime64(now(), 3))─┐ +│ 2023-05-12 01:16:59.000 │ +└────────────────────────────────────────────────────────────────────────────┘ +``` + +:::note +The type returned is a DateTime64 as the DataTime32 must be promoted to 64 bit for the comparison. +:::