THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL MIN() Function


MIN () function

MIN () function returns the minimum value of the specified column.

SQL MIN () syntax

SELECT MIN (column_name) FROM table_name;


Demo database

In this tutorial, we will use the welookups sample database.

Here is the data from the "Websites" table:

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/  | 1     | USA     |
| 2  | Indiatimes          | https://www.Indiatimes.com/ | 13    | IN      |
| 3  | zomato      | http://www.zomato.com/  | 4689  | IN      |
| 4  | indiamart          | http://indiamart.com/       | 20    | IN      |
| 5  | Facebook     | https://www.facebook.com/| 3     | USA     |
|  6 | Yahoo         | https://www.Yahoo.com/  |     4 | IN      |
|  7 | stackoverflow | http://stackoverflow.com/|     0 | IND     |
+----+---------------+---------------------------+-------+---------+


SQL MIN () instance

The following SQL statement gets the minimum value from the "alexa" column of the "Websites" table:

Example

SELECT MIN (alexa) AS min_alexa FROM Websites;

The results of executing the above SQL are as follows: