SQL MIN()
Function
MIN() Function
The MIN() function returns the smallest value of the specified column.
SQL MIN() Syntax
Demonstration Database
In this tutorial, we will use the tutorialpro sample database.
Below is the data from the "Websites" table:
+----+--------------+---------------------------+-------+---------+
| id | name | url | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1 | Google | https://www.google.cm/ | 1 | USA |
| 2 | Taobao | https://www.taobao.com/ | 13 | CN |
| 3 | tutorialpro.org | http://www.tutorialpro.org/ | 4689 | CN |
| 4 | Weibo | http://weibo.com/ | 20 | CN |
| 5 | Facebook | https://www.facebook.com/ | 3 | USA |
| 6 | Baidu | https://www.baidu.com/ | 4 | CN |
| 7 | Stackoverflow | http://stackoverflow.com/ | 0 | IND |
+----+---------------+---------------------------+-------+---------+
SQL MIN() Example
The following SQL statement retrieves the minimum value from the "alexa" column of the "Websites" table:
Example
The result of the above SQL execution is as follows: