MIN( )

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Retrieves the minimum value in a column. Available in gpre, DSQL, and isql.

MIN ([ALL] val | DISTINCT val)
Argument Description

ALL

Searches all values in a column

DISTINCT

Eliminates duplicate values before finding the smallest

<val>

A column, constant, host-language variable, expression, non-aggregate function, or UDF

Description: MIN() is an aggregate function that returns the smallest value in a specified column, excluding NULL values. If the number of qualifying rows is zero, MIN() returns a NULL value.

When MIN() is used on a CHAR, VARCHAR, or Blob text column, the smallest value returned varies depending on the character set and collation in use for the column. Use the DEFAULT CHARACTER SET clause in CREATE DATABASE to specify a default character set for an entire database, or the COLLATE clause in CREATE TABLE to specify a character set at the column level.

Example: The following embedded SQL statement demonstrates the use of SUM(), AVG(), MIN(), and MAX():

EXEC SQL
SELECT SUM (BUDGET), AVG (BUDGET), MIN (BUDGET), MAX (BUDGET)
FROM DEPARTMENT
WHERE HEAD_DEPT = :head_dept
INTO :tot_budget, :avg_budget, :min_budget, :max_budget;

See Also