Databases Reference
In-Depth Information
Table 6-12. Each pub l isher's cheapest book under $20.00
PubName
Minimum Price
A lpha Press
$ 12.00
B ig House
$ 15.00
Note that the WHERE clause restricts which rows participate in the grouping and hence
contribute to the value of the aggregate functions, whereas the HAVING clause affects
only which values are displayed.
6.7.3.7 ORDER BY OrderByCriteria
The ORDER BY option describes the order in which to return the rows in the return
table. The OrderByCriteria has the form:
OrderByCriteria ::= { ColumnName [ASC | DESC ]},...
In other words, it is just a list of columns to use in the ordering. Rows are sorted first by
the first column listed, then rows with identical values in the first column are sorted by
the values in the second column, and so on.
6.7.4 The UNION Statement
The UNION statement is used to create the union of two or more tables. The syntax is:
[TABLE] Query
{UNION [ALL] [TABLE] Query },...
where Query is either a SELECT statement, the name of a stored query, or the name of a
stored table preceded by the TABLE keyword. The ALL option forces Access to include
all records. Without this option, Access does not include duplicate rows. The use of ALL
increases performance as well and is thus recommended even when there are no duplicate
rows.
6.7.4.1 Example
The following statement takes the union of all rows of BOOKS and those rows of
NEWBOOKS that have Price > $25.00, sorting the result table by Title:
TABLE BOOKS
UNION ALL
SELECT * FROM NEWBOOKS WHERE Price > 25.00
ORDER BY Title;
6.7.4.2 Notes
All queries in a UNION operation must return the same number of fields.
However, the fields do not need to have the same size or data type.
Search WWH ::




Custom Search