当前位置:首页 » 编程语言 » sql课程高于平均课程的成绩
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

sql课程高于平均课程的成绩

发布时间: 2022-09-18 20:05:26

‘壹’ 用sql语言找出每个学生超过他自己平均成绩的学号和课

SELECT dbo.student.id, dbo.student.name, dbo.student.age, dbo.student.class, dbo.curriculum.id AS Expr1, dbo.curriculum.name AS Expr2, dbo.curriculum.Firstclass,
dbo.Elective.score, Table1.avgscore
FROM dbo.student LEFT OUTER JOIN
dbo.Elective ON dbo.student.id = dbo.Elective.id LEFT OUTER JOIN
dbo.curriculum ON dbo.Elective.curriculumid = dbo.curriculum.id RIGHT OUTER JOIN
(SELECT id, AVG(score) AS avgscore
FROM dbo.Elective AS Elective_1
GROUP BY id) AS Table1 ON Table1.id = dbo.student.id AND dbo.Elective.score >= Table1.avgscore

‘贰’ 在数据库中如何使用sql语句查询:修了a12课程,且成绩高于此课程的平均成绩的学生的姓名和成绩急

select 姓名,成绩 from 表名 where a12=1 and 成绩>(select avg(成绩) from 表名)

‘叁’ 求所选每门课程成绩都大于该课程平均成绩的学生,求sql大神详解,

select * from student a,(select sid from score a,(select cid,avg(score) avg from score group by sid) b where a.cid = b.cid and score>avg group by sid have count(*)>=3) b where a.sid = b.sid

‘肆’ sql语句查询所有大于某门课程平均成绩的id以及该生本门课程的成绩

SELECT*
FROMCourseScore
WHERECourse='数学'
ANDScore>(
SELECTAVG(Score)
FROMCourseScore
WHERECourse='数学'
)

更通用一些的:

SELECTA.*
FROMCourseScoreA
JOIN(--查询各科目的平均成绩
SELECTCourse,AVG(Score)Average
FROMCourseScore
GROUPBYCourse
)BONA.Course=B.Course
WHEREA.Course=B.Course
ANDA.Score>B.Average
ORDERBYA.Course,A.ScoreDESC--按科目、成绩(倒序)

‘伍’ sql查询选修课同学成绩大于该课程平均成绩 的同学的学号姓名 以及该课程成绩

SELECT stuID,Grade
FROM sc
WHERE Grade >ALL(
SELECT AVG(Grade)
FROM sc
)

‘陆’ SQL语句查询每门课程分数都比该门课程平均分数高的学生 学号,姓名,性别,系编号)(表见问题补充)

那么你需要和每门功课平均分做对比啊!求出每门功课的平均分,再去对比,需要用到逻辑函数。

‘柒’ SQL语句 列出01课程成绩高于该课程平均分的学生所选的所有课程的姓名,课程名。

select a.sname,b.cname from student a,course b, sc c
where a.sno=c.sno and b.cno=c.cno
and a.sno in (
select d.sno from sc d where d.cno='01' and d.grade>
(select avg(grade) from sc where cno='01' )
)

‘捌’ sql中想查询每门课比全班平均分高的学生成绩信息,进行了分组,但无法进行筛选,求救!!!!

select StuName 姓名,Result 成绩,ClaID 班级号,CouID 课程号
from Student,Result
where Student.StuID=Result.StuID
group by stuname,result,claid,couid
having result>avg(result)
order by CouID,ClaID