1.1

Table Of Contents
Examples
To return a substring of the word hello, starting at the second character and continuing
until the end of the word, use the following clause:
VALUES SUBSTR('hello', 2)
The result is 'ello'.
To return a substring of the word hello, starting at the rst character and continuing for
two characters, use the following clause:
VALUES SUBSTR('hello',1,2)
The result is 'he'.
SUM function
SUM is an aggregate function that evaluates the sum of the expression over a set of rows . SUM is allowed only
on expressions that evaluate to numeric data types.
Syntax
SUM ( [ DISTINCT | ALL ] Expression )
The DISTINCT and ALL qualiers eliminate or retain duplicates. ALL is assumed if neither ALL nor DISTINCT
is specied. For example, if a column contains the values 1, 1, 1, 1, and 2, SUM(col) returns a greater value than
SUM(DISTINCT col).
Only one DISTINCT aggregate expression per SelectExpression on page 526 is allowed. For example, the
following query is not allowed:
SELECT AVG (DISTINCT flying_time), SUM (DISTINCT miles)
FROM Flights
The Expression can contain multiple column references or expressions, but it cannot contain another aggregate
or subquery. It must evaluate to a built-in numeric data type. If an expression evaluates to NULL, the aggregate
skips that value.
The resulting data type is the same as the expression on which it operates (it might overow).
Examples
-- find all economy seats available:
SELECT SUM (economy_seats) FROM Airlines;
-- use SUM on multiple column references
-- (find the total number of all seats purchased):
SELECT SUM (economy_seats_taken + business_seats_taken +
firstclass_seats_taken)
as seats_taken FROM FLIGHTAVAILABILITY;
TAN function
The TAN function returns the tangent of a specied number.
The specied number is the angle, in radians, that you want the tangent for. The specied number must be a
DOUBLE PRECISION on page 609 number.
If the specied number is NULL, the result of this function is NULL.
569
SQL Language Reference