The query expression for a SQL derived table is specified in the from clause of the select or select into command in place of a table or view name:
from_clause ::= from table_reference [,table_reference]...
table_reference ::= table_view_name | ANSI_join
table_view_name ::= {table_view_reference | derived_table_reference} [holdlock | noholdlock] [readpast] [shared]
table_view_reference ::= [[database.]owner.] {table_name | view_name} [[as] correlation_name] [index {index_name | table_name }] [parallel [degree_of_parallelism]] [prefetch size ] [lru | mru]
derived_table_reference ::= derived_table [as] correlation_name [’(’ derived_column_list’)’]
derived_column_list ::= column_name [’,’ column_name] ...
derived_table ::= ’(’ select ’)’
A derived table expression is similar to the select in a create view statement and follows the same rules, with the following exceptions:
Temporary tables are permitted in a derived table expression except when it is part of a create view statement.
A local variable is permitted in a derived table expression except when it is part of a create view statement. You cannot assign a value to a variable within a derived table expression.
A correlation_name, which must follow the derived table expression to specify the name of the SQL derived table, may omit a derived column list, whereas a view cannot have unnamed columns:
select * from (select sum(advance) from total_sales) dt
For information on view restrictions, see “Restrictions on views” in create view in the Reference Manual.
Copyright © 2005. Sybase Inc. All rights reserved. |