How to select the largest value in MySQL?
To return the largest value from a column, MAX() function is used.
Here is the syntax:
Example:
Look at the following "Orders" table. Now we want to find the largest value of the "OrderPrice" column.
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.
| OrderId | OrderDate | OrderPrice |
|---|---|---|
| 1 | 2010/11/12 | 1000 |
| 2 | 2010/10/23 | 1600 |
| 3 | 2010/09/02 | 700 |
| 4 | 2010/09/03 | 300 |
| 5 | 2010/08/30 | 2000 |
| 6 | 2010/10/04 | 100 |
This can be done by using this statement:
SELECT MAX(OrderPrice) FROM Orders
Result:
2000
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment