How to select the largest value in MySQL?

To return the largest value from a column, MAX() function is used.
Here is the syntax:


SELECT MAX(column_name) FROM table_name



Example:
Look at the following "Orders" table. Now we want to find the largest value of the "OrderPrice" column.


OrderIdOrderDateOrderPrice
12010/11/121000
22010/10/231600
32010/09/02700
42010/09/03300
52010/08/302000
62010/10/04100


This can be done by using this statement:

SELECT MAX(OrderPrice) FROM Orders

Result:
2000

No comments:

Post a Comment