當前位置:首頁 » 編程語言 » 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