Instruire
Modul
Combine query results with set operators - Training
Combine query results with set operators using Transact-SQL.
Acest browser nu mai este acceptat.
Faceți upgrade la Microsoft Edge pentru a profita de cele mai noi funcții, actualizări de securitate și asistență tehnică.
+
(plus sign) operatorApplies to: Databricks SQL
Databricks Runtime
Returns the sum of expr1
and expr2
.
expr1 + expr2
expr1
: A numeric, DATE, TIMESTAMP, or INTERVAL expression.expr2
: If expr1
is a numeric expr2
must be numeric expression, or an INTERVAL otherwise.expr1
is a numeric, the common maximum type of the arguments.expr1
is a DATE and expr2
is a day-time interval the result is a TIMESTAMP.expr1
and expr2
are year-month intervals the result is a year-month interval of sufficiently wide units to represent the result.expr1
and expr2
are day-time intervals the result is a day-time interval of sufficiently wide units to represent the result.expr1
.If both expressions are interval they must be of the same class.
When you add a year-month interval to a DATE, Azure Databricks ensures that the resulting date is well formed.
If the result overflows the result type, Azure Databricks raises an ARITHMETIC_OVERFLOW error.
Use try_add to return NULL
on overflow.
Avertisment
In Databricks Runtime, if spark.sql.ansi.enabled is false
, an overflow does not cause an error but “wraps” the result instead.
> SELECT 1 + 2;
3
> SELECT DATE'2021-03-20' + INTERVAL '2' MONTH
2021-5-20
> SELECT TIMESTAMP'2021-03-20 12:15:29' + INTERVAL '3' SECOND
2021-03-20 12:15:32
> SELECT typeof(INTERVAL '3' DAY + INTERVAL '2' HOUR)
interval day to hour
> SELECT DATE'2021-03-31' + INTERVAL '1' MONTH;
2021-04-30
> SELECT 127Y + 1Y;
Error: ARITMETIC_OVERFLOW
Instruire
Modul
Combine query results with set operators - Training
Combine query results with set operators using Transact-SQL.
Documentație
& (ampersand sign) operator - Azure Databricks - Databricks SQL
Learn the syntax of the & (ampersand sign) operator of the SQL language in Databricks SQL.
curdate function - Azure Databricks - Databricks SQL
Learn the syntax of the curdate function of the SQL language in Databricks Runtime.
ascii function - Azure Databricks - Databricks SQL
Learn the syntax of the ascii function of the SQL language in Databricks SQL and Databricks Runtime.