ALLBASE/SQL Reference Manual (36216-90216)

116 Chapter3
SQL Queries
Complex Queries
Complex Queries
In addition to the simple queries shown in the previous section, you can create complex
queries, which may contain more than one SELECT statement. At the highest level, a query
is a SELECT statement, which consists of a query expression followed by an optional ORDER
BY clause. At the next lower level, you can combine different query blocks into a single
query expression with the UNION operator. Lower still, inside each query block is an
optional search condition, which can contain predicates that incorporate subqueries. A
subquery is always a single query block (SELECT) that can contain other subqueries but
cannot contain a UNION. A query expression can contain a maximum of 16 query blocks
from all sources, including UNION, subqueries, and the outer query block.
Figure 3-1. shows the range of possibilities for complex queries.
Figure 3-1. Range of Complex Query Types