本文分享一段mysql脚本,学习mysql使用Max()函数返回最大值的方法。
例子:
mysql> CREATE TABLE sales_rep(
-> employee_number INT,
-> surname VARCHAR(40),
-> first_name VARCHAR(30),
-> commission TINYINT
-> );
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO sales_rep values(4,'Rive','Mongane',10);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO sales_rep values(5,'Smith','Mike',12);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT MAX(commission) from sales_rep; --//使用Max()函数返回最大值
+-----------------+
| MAX(commission) |
+-----------------+
| 12 |
+-----------------+
1 row in set (0.00 sec)
mysql> drop table sales_rep;
Query OK, 0 rows affected (0.00 sec)