A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-expression below:

SQL expression | Databricks Documentation

SQL expression

Applies to: Databricks SQL Databricks Runtime

An expression is a formula that computes a result based on literals or references to columns, fields, or variables, using functions or operators.

Syntax​
{ literal |
named_parameter_marker |
unnamed_parameter_marker |
column_reference |
field_reference |
parameter_reference |
CAST expression |
CASE expression |
COLLATE expression |
expr operator expr |
operator expr |
expr [ expr ] |
function_invocation |
( expr ) |
( expr, expr [, ... ] ) |
scalar_subquery }

scalar_subquery
( query )

The brackets in expr [ expr ] are actual brackets and do not indicate optional syntax.

Parameters​

The pages for each function and operator describe the data types their parameters expect. Databricks performs implicit casting to expected types using SQL data type rules. If an operator or function is invalid for the provided argument, Databricks raises an error.

See Column, field, parameter, and variable resolution for more information on name resolution.

Constant expression​

An expression that is based only on literals or deterministic functions with no arguments. Databricks can execute the expression and use the resulting constant where ordinarily literals are required.

Boolean expression​

An expression with a result type of BOOLEAN. A Boolean expression is also sometimes referred to as a condition or a predicate.

Scalar subquery​

An expression of the form ( query ). The query must return a table that has one column and at most one row.

If the query returns no row, the result is NULL. If the query returns more than one row, Databricks returns an error. Otherwise, the result is the value returned by the query.

Simple expression​

An expression that does not contain a query, such as a scalar subquery or an EXISTS predicate.

Examples​

SQL

> SELECT 1;
1

> SELECT (SELECT 1) + 1;
2

> SELECT 1 + 1;
2

> SELECT 2 * (1 + 2);
6

> SELECT 2 * 1 + 2;
4

> SELECT substr('Spark', 1, 2);
Sp

> SELECT c1 + c2 FROM VALUES(1, 2) AS t(c1, c2);
3

> SELECT a[1] FROM VALUES(array(10, 20)) AS T(a);
20

> SELECT true;
true

> SELECT (c1, (c2, c3)) FROM VALUES(1, 2, 3) AS T(c1, c2, c3);
{"c1":1,"col2":{"c2":2,"c3":3}}
Related articles​

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4