ALLBASE/SQL Reference Manual (36216-90216)

110 Chapter3
SQL Queries
Using the SELECT Statement
Using the SELECT Statement
Use the SELECT statement to compose queries. The SELECT statement consists of the
following components:
1. Select list
2. INTO clause
3. FROM clause
4. WHERE clause
5. GROUP BY clause
6. HAVING clause
7. ORDER BY clause
The select list and FROM clause are required; all other components of this statement are
optional. The following example does not contain an INTO clause. Note the reference
numbers identifying the above components:
1
|
_______________|_____________
| |
| |
SELECT PartNumber, COUNT(VendorNumber)
FROM PurchDB.SupplyPrice ---3
WHERE DeliveryDays < 25 ---4
GROUP BY PartNumber ---5
HAVING COUNT(VendorNumber) > 2 ---6
ORDER BY PartNumber ---7
The result is presented in the form of a table, called a query result. The result table
(shown next) for this example has two columns: part numbers and a count of vendors who
supply each part. The query result has rows only for parts that can be delivered in fewer
than 25 days by more than two suppliers. The rows are ordered in ascending order by
PartNumber.
----------------+-----------
PARTNUMBER |(EXPR)
----------------+-----------
1123-P-01 | 4
1133-P-01 | 3
1243-MU-01 | 3
1323-D-01 | 3
1353-D-01 | 3
1433-M-01 | 3
.
.
.