早教吧 育儿知识 作业答案 考试题库 百科 知识分享

mysql判断最大值,最小值,第二大,第三大一共四个值

题目详情
mysql 判断最大值,最小值,第二大,第三大 一共四个值
▼优质解答
答案和解析
最大值:select max(num) from table
第二大值:select max(num) from table
where num not in(select max(num) from table)
第三大值:select max(num) from table
where num not in(select max(num) from table
where num not in(select max(num) from table))
最小值:select min(num) from table