MySQL Get Maximum Value
Write a mysql statement to get item id, item, price of the most expensive item
Suppose the item table is -
+-----------+--------------+----------------+
| ITEM_ID | ITEM | PRICE |
+-----------+--------------+----------------+
| 1001 | Book | 1200 |
| 1002 | Pen | 930 |
| 1003 | Bag | 1430 |
| 1004 | Copy | 1030 |
+-----------+--------------+----------------+
Solution:
MySQL MAX() function returns maximum value in a set of values. It accepts one argument i.e. the expression and returns the highest value of the expression. This expression is the required parameter.
The following statement returns maximum price in set of price list of items.
Output of the above code -
need an explanation for this answer? contact us directly to get an explanation for this answer+---------+------+-------+ | ITEM_ID | ITEM | PRICE | +---------+------+-------+ | 1003 | Bag | 1430 | +---------+------+-------+