SELECT (with Derived Column List)
TDV supports a derived column list in the SELECT statements.
Syntax
<table primary> ::=
<table or query name> [ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
<derived column list> ::= <column name list>
<column name list> ::= <column name> [ { <comma> <column name> }... ]
Example 1 (Derived Column List in Tables)
select * from /shared/examples/ds_inventory/tutorial/employees sub (a, b, c) where a = 2
The above query returns the following:
a b c title extension workphone
2 AnnMarie Catcher Systems\ Support 23 (650)\ 929-3000
Notice that the first 3 columns from the table (Employee Id, First Name and Last Name) displays as “a”, “b” and “c” as specified in the derived column list.
Example 2 (Derived Column List in Procedures)
SELECT x, y FROM LookupProcedure(2) AS alias01 (x, y)
Example 3 (Derived Column List in Derived Tables)
SELECT x, y FROM (select blue, clue, red FROM bar) as alias02 (x, y)
Remarks
• There will be an exception thrown when the no. of table column projections and the number of columns defined in the “alias” do not match.
• There will be an exception thrown when there are duplicate columns defined in the alias.