标签:var min null from distinct sql查询 mingzi create bsp
CREATE DATABASE kk;
USE kk;
CREATE TABLE fenshubiao
( id INT PRIMARY KEY AUTO_INCREMENT,
mingzi VARCHAR(10),
fenshu FLOAT
);
DESC fenshubiao
INSERT INTO fenshubiao VALUES(NULL,‘aa‘,95.0);
第一种办法:
SELECT MAX(fenshu) AS second_fenshu FROM fenshubiao WHERE fenshu<(SELECT MAX(fenshu) FROM fenshubiao); SELECT * FROM fenshubiao;
第二种办法;
SELECT IFNULL ( (SELECT DISTINCT fenshu FROM fenshubiao ORDER BY fenshu DESC LIMIT 1,1 ), NULL ) AS second_fenshu ;
标签:var min null from distinct sql查询 mingzi create bsp
原文地址:https://www.cnblogs.com/wangchao422/p/9508888.html