Returns the lowest value in a column.
min(expression)
is a column name, constant, function, any combination of column names, constants, and functions connected by arithmetic or bitwise operators, or a subquery. With aggregates, an expression is usually a column name. For more information, see “Expressions”.
select min(price) from titles where type = "psychology"
------------------------ 7.00
min, an aggregate function, finds the minimum value in a column.
For general information about aggregate functions, see “Aggregate functions”.
You can use min with numeric, character, time, and datetime columns; you cannot use it with bit columns. With character columns, min finds the lowest value in the sort sequence. min implicitly converts char datatypes to varchar, and unichar datatypes to univarchar, stripping all trailing blanks. min ignores null values. distinct is not available, since it is not meaningful with min.
unichar data is collated according to the default Unicode sort order.
Adaptive Server goes directly to the first qualifying row for min when there is an index on the aggregated column, unless:
The expression is not a column.
The column is not the first column of an index.
There is another aggregate in the query.
There is a group by clause.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute min.
Commands compute clause, group by and having clauses, select, where clause
Copyright © 2005. Sybase Inc. All rights reserved. |