MIN is an aggregate function that evaluates the minimum of an expression over a set of rows.
See Aggregates (set functions) for more information about these functions.
MIN is allowed only on expressions that evaluate to indexable data types (specifically, those marked with a Y in the second table, "Comparisons allowed by Derby", in Data type assignments and comparison, sorting, and ordering). This means that MIN cannot be used with expressions that evaluate to BLOB, CLOB, LONG VARCHAR, LONG VARCHAR FOR BIT DATA, XML, or user-defined types.
MIN ( [ DISTINCT | ALL ] expression )
SELECT COUNT (DISTINCT flying_time), MIN (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 minimum value. For CHAR and VARCHAR, the number of blank spaces at the end of the value can affect how MIN 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 minimum, 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).
-- NOT valid: SELECT DISTINCT flying_time, MIN(DISTINCT miles) from Flights -- valid: SELECT COUNT(DISTINCT flying_time), MIN(DISTINCT miles) from Flights -- find the earliest date: SELECT MIN (flight_date) FROM FlightAvailability;