SQL MAX

SQL MAX

The SQL MAX function returns the maximum value in a select query.

MAX syntax

SELECT MAX(table_column)
FROM table_name;

MAX example

Coder books table

ID Title Price Description
1 Learn SQL 20 Learn SQL language
2 Learn MySQL 22 Learn MySQL language
3 HTML book 17 Learn HTML
4 Learn PHP 20 Introduction to PHP
5 Learn PHP 20 PHP course
SELECT MAX(price) 
FROM coder_books;

Result

22

SELECT price, MAX(price) max_price
FROM coder_books
GROUP BY price
HAVING count(*) > 1;

Result

Price max_price
20 20