The select expression is a query expression introduced by the keyword SELECT. A select expression produces a derived table.
The select expression is made up of a number of individual clauses, each of which relates to a specific operation. These clauses jointly produce the final derived table.
select list: this specifies the columns of the derived table.
FROM clause: this specifies the tables; the derived table is the Cartesian product of these tables.
If two or more tables are specified in the FROM clause, the result is the Cartesian product of these tables. The Cartesian product of two tables is produced by concatenating all the rows of the first table with all the rows of the second table. The number of rows of the Cartesian product thus corresponds to the product of the number of rows in the underlying tables.
WHERE clause: this specifies a search condition. The derived table comprises those rows of the derived table produced by the FROM clause which match the search condition.
The join condition is a special form of a search condition in the WHERE clause. This allows data from two or more tables to be linked. A join condition across two tables is formulated by linking one column in one of the tables to a corresponding column in the other table with a comparison operator. Only those rows are selected from the Cartesian product of the two tables which fulfil this join condition. The link between the two tables (and sometimes the resultant derived table) is referred to as a join).
In addition to the option of linking tables by a join condition in the WHERE clause, there is the more detailed option of formulating joins on the basis of join expressions. Join expressions are described on "Join expression".
GROUP BY clause: this specifies grouping attributes. The derived table is the same as the derived table from the WHERE clause, except that the rows are grouped according to the values in the grouping attributes.
If the GROUP BY clause is not specified, the table is not arranged in groups.HAVING clause: this allows you to specify a search condition. The derived table comprises those groups which match the search condition.
The correct sequence of clauses must be observed in the select expression. The derived table is built step by step in the same sequence specified in the select expression, with the exception of the select list. This is only evaluated after the FROM, WHERE, GROUP BY and HAVING clauses have been evaluated.