题目 : https://www.nowcoder.com/practice/7dbc7fef4f3f4ab09a01c210fcb770ce?tpId=341
数据
drop table if exists questions_pass_record_detail;
CREATE TABLE `questions_pass_record_detail` (
`user_id` int NOT NULL,
`question_type` varchar(32) NOT NULL,
`device` varchar(14) NOT NULL,
`pass_count` int NOT NULL,
`date` date NOT NULL);
INSERT INTO questions_pass_record_detail VALUES(101, 'java', 'app', 2, '2020-03-01');
INSERT INTO questions_pass_record_detail VALUES(102, 'sql', 'pc', 15,'2021-07-07');
INSERT INTO questions_pass_record_detail VALUES(102, 'python', 'pc', 9, '2021-04-09');
INSERT INTO questions_pass_record_detail VALUES(104, 'python', 'app', 3,'2022-03-17');
INSERT INTO questions_pass_record_detail VALUES(105, 'sql', 'pc', 60, '2016-08-15');
INSERT INTO questions_pass_record_detail VALUES(204, 'sql', 'pc', 20, '2019-05-15');
需求
查询 sql 类题目的单次最大刷题数
查询结果 :
max(pass_count)
60
解决
注意 :
- max : 找到该列的最大值
select
max(pass_count)
from questions_pass_record_detail
where question_type = 'sql';