1.1

Table Of Contents
Syntax
FROM table-expression [ , table-expression ] *
Description
The FROM clause is a mandatory clause in a select-expression. It species the tables (table-expression) from
which the other clauses of the query can access columns for use in expressions.
Example
SELECT CUST_NAME FROM TRADE.CUSTOMERS WHERE CID < 5
-- other types of TableExpressions
SELECT TABLENAME, ISINDEX
FROM SYS.SYSTABLES T, SYS.SYSCONGLOMERATES C
WHERE T.TABLEID = C.TABLEID
ORDER BY TABLENAME, ISINDEX
-- force the join order
SELECT * FROM TRADE.SECURITIES S, TRADE.PORTFOLIO F WHERE
SEC_ID = F.SID AND F.TID = ?
-- a TableExpression can be a joinOperation. Therefore
-- you can have multiple join operations in a FROM clause
SELECT * FROM TRADE.CUSTOMERS C LEFT OUTER JOIN
TRADE.PORTFOLIO F LEFT OUTER JOIN TRADE.SELLORDERS SO ON F.CID
= SO.CID ON C.CID= F.CID
WHERE SO.SID < 100 AND SO.QTY > 500
GROUP BY Clause
Group a result into subsets that have matching values for one or more columns.
Syntax
GROUP BY column-name [ , column-name ] *
Description
A GROUP BY clause, part of a SelectExpression , groups a result into subsets that have matching values for
one or more columns. In each group, no two rows have the same value for the grouping column or columns.
NULLs are considered equivalent for grouping purposes.
You typically use a GROUP BY clause in conjunction with an aggregate expression.
column-name must be a column from the current scope of the query; there can be no columns from a query block
outside the current scope. For example, if a GROUP BY clause is in a subquery, it cannot refer to columns in
the outer query.
SQLFire does not support using GROUP BY on a column of datatype BLOB, CLOB, or LONG VARCHAR
FOR BIT DATA.
SelectItems in the SelectExpression with a GROUP BY clause must contain only aggregates or grouping
columns.
Example
-- find the quantity of units held by customer grouped by
customer ID
SELECT AVG (QTY), CID FROM TRADE.PORTFOLIO GROUP BY CID
SELECT MAX(F.QTY), C.CID FROM TRADE.PORTFOLIO F,
TRADE.CUSTOMERS C
WHERE F.CID = C.CID GROUP BY C.CID
519
SQL Language Reference