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

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

最大值: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

select max(字段名) from tableName limit 0,1 最大

select min(字段名) from tableName limit 0,1 最小

select * from tableName order by 字段名 DESC limit 0,1 最大

select * from tableName order by 字段名 ASC limit 0,1 最小


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7633216.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-08
下一篇 2023-04-08

发表评论

登录后才能评论

评论列表(0条)

保存