(一)查询出排序中的最大值和最小值
两种方法:
1. 使用max或者min函数
select max(age),min(age) from user2;
结果:
2. 使用order by 和limit 结合使用
- 取最大值
select age from user2 order by age desc limit 1;
- 取最小值
select age from user2 order by age limit 1;
select max(age),min(age) from user2;
结果:
select age from user2 order by age desc limit 1;
select age from user2 order by age limit 1;