SELECT statement
602
The FIRST and TOP keywords cannot be used in a derived table query. You
should not use the keywords in view definitions.
select list The select list is a list of expressions, separated by commas,
specifying what will be retrieved from the database. An asterisk (*) means to
select all columns of all tables in the FROM clause.
Aggregate functions are allowed in the select list (see "SQL Functions" on
page 303). Subqueries are also allowed in the select list (see "Expressions"
on page 230). Each subquery must be within parentheses.
Alias-names can be used throughout the query to represent the aliased
expression.
Alias names are also displayed by Interactive SQL at the top of each column
of output from the SELECT statement. If the optional alias name is not
specified after an expression, Interactive SQL will display the expression
itself.
INTO host-variable-list This clause is used in Embedded SQL only. It
specifies where the results of the SELECT statement will go. There must be
one host-variable item for each item in the select list. Select list items are put
into the host variables in order. An indicator host variable is also allowed
with each host-variable, so the program can tell if the select list item was
NULL.
INTO variable-list This clause is used in procedures and triggers only. It
specifies where the results of the SELECT statement will go. There must be
one variable for each item in the select list. Select list items are put into the
variables in order.
FROM clause Rows are retrieved from the tables and views specified in
the table expression. Joins can be specified using join operators. A SELECT
statement with no FROM clause can be used to display the values of
expressions not derived from tables. For example:
SELECT @@version
displays the value of the global variable @@version. This is equivalent to:
SELECT @@version
FROM DUMMY
$ For more information, see "FROM clause" on page 532.