You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function returns the maximum value from a list of one or more expressions.
26
+
27
+
> [!Note]
28
+
> `GREATEST` is currently available for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)], and serverless SQL pools in [!INCLUDE[ssazuresynapse_md](../../includes/ssazuresynapse_md.md)].
28
29
29
30
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
A list of comma-separated expressions of any comparable data type. The `GREATEST` function requires at least one argument and supports no more than 254 arguments.
40
41
41
-
Each expression can be a constant, variable, column name or function, as well as any combination of arithmetic, bitwise and string operators. Aggregate functions and scalar subqueries are permitted.
42
+
Each expression can be a constant, variable, column name or function, and any combination of arithmetic, bitwise, and string operators. Aggregate functions and scalar subqueries are permitted.
42
43
43
44
## Return Types
44
45
Returns the data type with the highest precedence from the set of types passed to the function. For more information, see [Data Type Precedence (Transact-SQL)](../../t-sql/data-types/data-type-precedence-transact-sql.md).
If implicit type conversion between the arguments is not supported, the function will fail and return an error.
58
59
59
-
See [Data Type Conversion (Database Engine)](../../t-sql/data-types/data-type-conversion-database-engine.md) for further details on implicit and explicit conversion.
60
+
For more information on implicit and explicit conversion, see [Data Type Conversion (Database Engine)](../../t-sql/data-types/data-type-conversion-database-engine.md).
60
61
61
-
If one or more arguments are not null, then null arguments will be ignored during comparison. If all arguments are null, then `GREATEST` will return null.
62
+
If one or more arguments are not `NULL`, then `NULL` arguments will be ignored during comparison. If all arguments are `NULL`, then `GREATEST` will return `NULL`.
62
63
63
64
Comparison of character arguments follows the rules of [Collation Precedence (Transact-SQL)](../../t-sql/statements/collation-precedence-transact-sql.md).
64
65
65
-
The following types are **not** supported for comparison in `GREATEST`: **varchar(max), varbinary(max) or nvarchar(max) exceeding 8,000 bytes, cursor, geometry, geography, image, non-byte-ordered user-defined types, ntext, table, text** and **xml**.
66
+
The following types are **not** supported for comparison in `GREATEST`: **varchar(max), varbinary(max) or nvarchar(max) exceeding 8,000 bytes, cursor, geometry, geography, image, non-byte-ordered user-defined types, ntext, table, text**, and **xml**.
66
67
67
-
The varchar(max), varbinary(max) and nvarchar(max) data types are supported for arguments that are 8,000 bytes or below, and will be implicitly converted to varchar(n), varbinary(n) and nvarchar(n), respectively, prior to comparison.
68
+
The varchar(max), varbinary(max), and nvarchar(max) data types are supported for arguments that are 8,000 bytes or below, and will be implicitly converted to varchar(n), varbinary(n), and nvarchar(n), respectively, prior to comparison.
68
69
69
70
For example, varchar(max) can support up to 8,000 characters if using a single-byte encoding character set, and nvarchar(max) can support up to 4,000 byte-pairs (assuming UTF-16 character encoding).
This function returns the minimum value from a list of one or more expressions.
25
+
26
+
> [!Note]
27
+
> `LEAST` is currently available for [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], [!INCLUDE[ssazuremi_md](../../includes/ssazuremi_md.md)], and serverless SQL pools in [!INCLUDE[ssazuresynapse_md](../../includes/ssazuresynapse_md.md)].
28
28
29
29
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
A list of comma-separated expressions of any comparable data type. The `LEAST` function requires at least one argument and supports no more than 254 arguments.
40
40
41
-
Each expression can be a constant, variable, column name or function, as well as any combination of arithmetic, bitwise and string operators. Aggregate functions and scalar subqueries are permitted.
41
+
Each expression can be a constant, variable, column name or function, and any combination of arithmetic, bitwise, and string operators. Aggregate functions and scalar subqueries are permitted.
42
42
43
43
## Return Types
44
44
Returns the data type with the highest precedence from the set of types passed to the function. For more information, see [Data Type Precedence (Transact-SQL)](../../t-sql/data-types/data-type-precedence-transact-sql.md).
If implicit type conversion between the arguments is not supported, the function will fail and return an error.
58
58
59
-
See [Data Type Conversion (Database Engine)](../../t-sql/data-types/data-type-conversion-database-engine.md) for further details on implicit and explicit conversion.
59
+
For more information on implicit and explicit conversion, see [Data Type Conversion (Database Engine)](../../t-sql/data-types/data-type-conversion-database-engine.md).
60
60
61
-
If one or more arguments are not null, then null arguments will be ignored during comparison. If all arguments are null, then `LEAST` will return null.
61
+
If one or more arguments are not `NULL`, then `NULL` arguments will be ignored during comparison. If all arguments are `NULL`, then `LEAST` will return `NULL`.
62
62
63
63
Comparison of character arguments follows the rules of [Collation Precedence (Transact-SQL)](../../t-sql/statements/collation-precedence-transact-sql.md).
64
64
65
-
The following types are **not** supported for comparison in `LEAST`: **varchar(max), varbinary(max) or nvarchar(max) exceeding 8,000 bytes, cursor, geometry, geography, image, non-byte-ordered user-defined types, ntext, table, text** and **xml**.
65
+
The following types are **not** supported for comparison in `LEAST`: **varchar(max), varbinary(max) or nvarchar(max) exceeding 8,000 bytes, cursor, geometry, geography, image, non-byte-ordered user-defined types, ntext, table, text**, and **xml**.
66
66
67
-
The varchar(max), varbinary(max) and nvarchar(max) data types are supported for arguments that are 8,000 bytes or below, and will be implicitly converted to varchar(n), varbinary(n) and nvarchar(n), respectively, prior to comparison.
67
+
The varchar(max), varbinary(max), and nvarchar(max) data types are supported for arguments that are 8,000 bytes or below, and will be implicitly converted to varchar(n), varbinary(n), and nvarchar(n), respectively, prior to comparison.
68
68
69
69
For example, varchar(max) can support up to 8,000 characters if using a single-byte encoding character set, and nvarchar(max) can support up to 4,000 byte-pairs (assuming UTF-16 character encoding).
0 commit comments