mysql max()函数,min()函数,获取最大值以及最小值

 

mysql> select * from table1;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date          |
+----------+------------+-----+---------------------+
| 1hahha   | 1xiaohong  |   1 | 2019-08-04 20:45:47 |
| 2hahha   | 2xiaohong  |   2 | 2019-08-04 20:45:57 |
| 3hahha   | 3xiaohong  |   3 | 2019-08-04 20:46:02 |
| 4hahha   | 4xiaohong  |   4 | 2019-08-04 20:46:05 |
| 3hahha   | bob        |   5 | 2019-08-04 20:46:08 |
| 3hahha   | lee        |   6 | 2019-08-04 20:46:12 |
+----------+------------+-----+---------------------+
6 rows in set (0.00 sec)


mysql> select max(pid) from table1;
+----------+
| max(pid) |
+----------+
|        6 |
+----------+
1 row in set (0.01 sec)


mysql> select min(pid) from table1;
+----------+
| min(pid) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

 

 

 

posted @ 2019-08-04 21:41  anobscureretreat  阅读(11466)  评论(0编辑  收藏  举报