LTRIM function
Derby Reference Manual
133
VALUES LOCATE('AAA', '')
-- returns 3
VALUES LOCATE('', '', 3)
LTRIM function
LTRIM removes blanks from the beginning of a character string expression.
Syntax
LTRIM(CharacterExpression)
A CharacterExpression is a CHAR, VARCHAR, or LONG VARCHAR data type, any
built-in type that is implicitly converted to a string.
LTRIM returns NULL if CharacterExpression evaluates to null.
Example
-- returns 'asdf '
VALUES LTRIM(' asdf ')
MAX function
MAX is an aggregate function that evaluates the maximum of an expression over a set of
rows (see
). MAX is allowed only on expressions that evaluate
to built-in data types (including CHAR, VARCHAR, DATE, TIME, CHAR FOR BIT DATA,
etc.).
Syntax
MAX ( [ DISTINCT | ALL ] Expression )
The DISTINCT and ALL qualifiers eliminate or retain duplicates, but these qualifiers
have no effect in a MAX expression. Only one DISTINCT aggregate expression per
is allowed. For example, the following query is not allowed:
SELECT COUNT (DISTINCT flying_time), MAX (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 data type. You can
therefore call methods that evaluate to built-in data types. (For example, a method that
returns a java.lang.Integer or int evaluates to an INTEGER.) If an expression evaluates to
NULL, the aggregate skips that value.
The type's comparison rules determine the maximum value. For CHAR and VARCHAR,
the number of blank spaces at the end of the value can affect how MAX is evaluated. For
example, if the values 'z' and 'z ' are both stored in a column, you cannot control which
one will be returned as the maximum, because blank spaces are ignored for character
comparisons.
The resulting data type is the same as the expression on which it operates (it will never
overflow).
Examples
-- find the latest date in the FlightAvailability table
SELECT MAX (flight_date) FROM FlightAvailability
-- find the longest flight originating from each airport,
-- but only when the longest flight is over 10 hours
SELECT MAX(flying_time), orig_airport