WITH Clause Syntax | SQL SELECT Statements | Teradata Vantage - WITH Clause Syntax - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
qtb1554762060450.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™
WITH expression_1 [,...] [ BY by_expr [,...] ] ] [...]

Syntax Elements

expression_1
An introduction to the condition to be fulfilled by the SELECT statement. Specifies a summary line, such as a total, for the values in a column of the select result. expression_1 can contain one or more aggregate expressions that are applied to column values.
You cannot include LOB columns in the WITH expression_1 list.
You cannot include a WITH clause with NORMALIZE.
by_expr
expression_2 [ ASC | DESC ]
expression_2
One or more result expressions for which expression_1 is provided. BY is valid only when used with WITH.
expression_2 can refer to an expression in the select expression list either by name or by means of a constant that specifies the numeric position of the expression in the expression list. It can also refer to a scalar subquery.
You cannot include LOB columns in the BY expression_2 list.
ASC
Results are to be ordered in ascending sort order.
If the sort field is a character string, the system orders it in ascending order according to the definition of the collation sequence for the current session.
The default order is ASC.
DESC
Results are to be ordered in descending sort order.
If the sort field is a character string, the system orders it in descending order according to the definition of the collation sequence for the current session.