MIN

Finds the smallest of the values in the argument (ASCII comparison for alphabetic types). Null values are ignored. MIN can be applied to numeric, character, and BINARY data types. See "Aggregate Functions" for more details on aggregate functions. MIN can also be an aggregate analytic function. See "Analytic Functions" for information.

SQL syntax

 MIN ([ALL | DISTINCT]{Expression|ROWID}) [OVER (AnalyticClause)]

Parameters

MIN has the parameters:

Parameter Description

Expression

Can be any numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type.

ALL

Includes any duplicate rows in the argument of an aggregate function. If neither ALL nor DISTINCT is specified, ALL is assumed.

DISTINCT

Eliminates duplicate column values from the argument of an aggregate function.

ROWID

TimesTen assigns a unique ID called a rowid to each row stored in a table. The rowid value can be retrieved through the ROWID pseudocolumn. See "ROWID Pseudocolumn" for more details.

OVER (AnalyticClause)

If specified, indicates aggregate analytic function. See "Analytic Functions" for more information on analytic functions.

Description

  • If the MIN function is computed over an empty table in which GROUP BY is not used, MIN returns NULL.

  • If the MIN function is computed over an empty group or an empty grouped table (GROUP BY is used), MIN returns nothing.

  • The result data type is the same as the source.

  • If you do not use the AnalyticClause in your query, then MIN acts as an aggregate function.

Examples

Show the smallest salary:

Command> SELECT MIN(salary) "Min Salary" FROM employees;
 
MIN SALARY
< 2100 >

Show the earliest hire date:

Command> SELECT MIN(hire_date) "Earliest Hire Date" FROM employees;
 
EARLIEST HIRE DATE
< 1987-06-17 00:00:00 >
1 row found.