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

IDTitlePriceDescription
1Learn SQL20Learn SQL language
2Learn MySQL22Learn MySQL language
3HTML book17Learn HTML
4Learn PHP20Introduction to PHP
5Learn PHP20PHP 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

Pricemax_price
2020