用sql语句,统计选修了VB课程的最高成绩和最低成绩的学生的学号和姓名?

来源:百度知道 编辑:UC知道 时间:2024/04/27 20:29:15

select 学号,姓名 from table where
成绩=(select max(成绩) from table where 课程='vb课程')
or
成绩=(select min(成绩) from table where 课程='vb课程')

select table.no.table.name
from table
where table.score =
(select t.max(score)
from table t
group by kecheng
having t.kecheng='VB' )
or table.score =
(select t.min(score)
from table t
group by kecheng
having t.kecheng='VB' )

select 学号,姓名 from 表名 where 成绩 in(select max(成绩),min(成绩)from 表名 where 课程名='vb')

最好把表结构拿出来,这样比较容易给你答案,否则光凭你这题目就能得出完全不同的答案N种。

MAX(成绩) MIN(成绩) 其他的不用说了把