WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL MAX() Function


MAX () function

MAX () function returns the maximum value of the specified column.

SQL MAX () syntax

SELECT MAX (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/ | 5000  | 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 MAX () example

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

Example

SELECT MAX (alexa) AS max_alexa FROM Websites;

The results of executing the above SQL are as follows: