The MIN() function will return the smallest value of the selected column.
The MIN function will be used to find the minimum value in an expression.
In other words, SQL MIN function will be used to find out the record with minimum value among a record set.
Syntax
The syntax for the MIN function is,
SELECT MIN (<expression>)
FROM "table_name";
<expression> can be a column name or an arithmetic operation. An arithmetic operation can include more than one column, such as ("column1" - "column2").
It is also possible to have one or more columns in addition to the MIN function in the SELECT statement. In those cases, these columns need to be part of the GROUP BY clause as well:
SELECT "column_name1", "column_name2", ... "column_nameN", MIN (<expression>)
FROM "table_name";
GROUP BY "column_name1", "column_name2", ... "column_nameN";
Examples
We use the following table for our examples.
Table Store_Information
Store_Name
Sales
Txn_Date
Los Angeles
1500
Jan-05-1999
San Diego
250
Jan-07-1999
Los Angeles
300
Jan-08-1999
Boston
700
Jan-08-1999
Example 1: MIN function on a column
To find the minimum sales amount, we type in,
SELECT MIN(Sales) FROM Store_Information;
Result:
250 represents the minimum value of all Sales entries: 1500, 250, 300, and 700.
Example 2: MIN function on an arithmetic operation
Assume that sales tax is 10% of the sales amount, we use the following SQL statement to get the minimum sales tax amount:
SELECT MIN(Sales*0.1) FROM Store_Information;
Result:
SQL will first calculate "Sales*0.1" and then apply the MIN function to the result for the final answer.
Example 3: MIN function with a GROUP BY clause
To get the minimum amount of sales for each store, we type in,
SELECT Store_Name, MIN(Sales) FROM Store_Information GROUP BY Store_Name;
This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf
Related Searches to MIN Function in SQL
sql min of two valuessql min of two columnssql min group bysql min and max in same querysql max and min in one selectsql select min value from multiple rowstsql minoracle min maxms access min functionms access minmin max oraclemin functionmin tableselect minsql select where mindb2 minsql minimum valuesql minimum date valuesql server get minimum datesql select minimum value rowpl sql minimum of two valuessql min datesql select row with min value