> 其他 >
查询“数学”成绩比‘李三’高,“英语”比‘李三’低的同学的姓名及“数学”的sql语句
人气:145 ℃ 时间:2020-05-28 01:38:15
解答
表结构给出来啊,还有你用什么数据库
select 姓名 from 学生表
where 学号 in
(select 学号 from 成绩表 where
课程号 in (select 课程号 from 课程表 where 课程名='数学')
and 成绩>
(select 成绩 as 数学成绩
from 学生表,课程表,成绩表 where 学生表.学号=成绩表.学号 and 课程表.课程号=成绩表.课程号
and 课程表.课程名='数学' and 学生表.姓名='李三')
union
select 学号 from 成绩表 where
课程号 in (select 课程号 from 课程表 where 课程名='英语')
and 成绩<
(select 成绩 as 英语成绩
from 学生表,课程表,成绩表 where 学生表.学号=成绩表.学号 and 课程表.课程号=成绩表.课程号
and 课程表.课程名='英语' and 学生表.姓名='李三') )
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版