Export (0) Print
Expand All
Expand Minimize
2 out of 7 rated this helpful - Rate this topic

MIN (Transact-SQL)

Returns the minimum value in the expression. May be followed by the OVER clause.

Topic link icon Transact-SQL Syntax Conventions


MIN ( [ ALL | DISTINCT ] expression ) 
ALL

Applies the aggregate function to all values. ALL is the default.

DISTINCT

Specifies that each unique value is considered. DISTINCT is not meaningful with MIN and is available for SQL-92 compatibility only.

expression

Is a constant, column name, or function, and any combination of arithmetic, bitwise, and string operators. MIN can be used with numeric, char, varchar, or datetime columns, but not with bit columns. Aggregate functions and subqueries are not permitted.

For more information, see Expressions (Transact-SQL).

Returns a value same as expression.

ms179916.note(en-US,SQL.90).gifImportant:
Distinct aggregates, for example AVG(DISTINCT column_name), COUNT(DISTINCT column_name), MAX(DISTINCT column_name), MIN(DISTINCT column_name), and SUM(DISTINCT column_name), are not supported when you use CUBE or ROLLUP. If they are used, Microsoft SQL Server 2005 Database Engine returns an error message and ends the query.

MIN ignores any null values.

With character data columns, MIN finds the value that is lowest in the sort sequence.

The following example returns the lowest (minimum) tax rate.

USE AdventureWorks;
GO
SELECT MIN(TaxRate)
FROM Sales.SalesTaxRate;
GO

Here is the result set.

-------------------
5.00

(1 row(s) affected)
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.