ALLBASE/SQL Reference Manual (36216-90216)

506 Chapter12
SQL Statements S - Z
SELECT
DISTINCT ensures that each row in the query result is unique. All null values are
considered equal. You cannot specify this option if the select list contains
an aggregate function with DISTINCT in the argument. This option
cannot be used for a select list longer than 255 items. Avoid DISTINCT in
subqueries since the query result is not changed, and it hinders rather
than helping performance.
SelectList
tells how the columns of the result table are to be derived. The syntax of
SelectList
is presented separately below.
INTO The INTO clause defines host variables for holding rows returned in
application programs. Do not use this clause for SELECT statements
associated with a cursor or dynamically preprocessed SELECT statements,
query blocks within subqueries, nested query expressions, or any but the
first query block in a SELECT statement.
HostVariableSpecification
identifies one or more host variables for holding rows
returned in application programs. Do not use this clause for SELECT
statements associated with a cursor or dynamically preprocessed SELECT
statements, query blocks within subqueries, nested query expressions, or
any but the first query block in a SELECT statement. The syntax of BULK
and non-BULK types of
HostVariableSpecification
are presented
separately below.
FROM The FROM clause identifies the tables and views referenced anywhere in
the SELECT statement. The maximum number of tables per query is 31.
FromSpec
identifies the tables and views in a query block and explicitly defines inner
and outer joins. The syntax of
FromSpec
is presented separately below.
WHERE The WHERE clause determines the set of rows to be retrieved. Rows for
which
SearchCondition1
is false or unknown are excluded from
processing. If the WHERE clause is omitted, no rows are excluded.
Aggregate functions cannot be used in the WHERE clause.
Rows that do not satisfy
SearchCondition1
are eliminated
before
groups
are formed and aggregate functions are evaluated.
When you are joining tables or views, the WHERE clause also specifies the
condition(s) under which rows should be joined. You cannot join on a
column in a view derived using a GROUP BY clause. If you omit a join
condition, ALLBASE/SQL joins each row in each table in the FROM clause
with each row in all other tables in the FROM clause.
SearchCondition1
may contain subqueries. Each subquery is effectively
executed for each row of the outer query and the results used in the
application of
SearchCondition1
to the given row. If any executed
subquery contains an outer reference to a column of a table or view in the
FROM clause, then the reference is to the value of that column in the
given row.
Refer to the "Search Conditions" chapter for additional information on
search conditions.
GROUP BY The GROUP BY clause identifies the columns to be used for grouping