LC/sql/looking/241022_1.sql
whaifree 72843c9027 feat(redo): 添加新的练习代码和解决方案
- 新增 LeetCode 69、135、376、763题目的解决方案
- 添加面试题练习代码
- 新建 SQL 查询练习题 stu,列 name, score, course,查询每一科分数大于 60 的学生姓名
2024-10-22 19:38:49 +08:00

25 lines
576 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- stu列 name, score, course查询每一科分数大于 60 的学生姓名
-- 创建表
create table stu(
id int primary key auto_increment,
name varchar(20),
score int,
course varchar(20)
);
-- 生成一些数据
insert into stu(name, score, course)
values ('张三', 70, '语文'),
('李四', 80, '语文'),
('王五', 60, '语文'),
('赵六', 90, '语文');
SELECT DISTINCT stu.name FROM stu where stu.name
not in( SELECT stu.name FROM stu WHERE stu.score<60);
SELECT name
FROM stu
GROUP BY name
HAVING MIN(score) > 60;