sql,查詢每門課程最高分的學生的學號,課程號,成績。再一張表裡

2021-12-31 20:55:53 字數 4087 閱讀 5701

1樓:電子科技小百科

1、首先在開啟的sql中,檢視market資料庫中**商來自哪些州的哪些城市,如下圖所示。

2、接著檢視market資料庫**商的完整資訊,如下圖所示。

3、然後檢視market資料庫中,**商來自哪些國家(去除重複國家)。

4、然後在stu資料庫中對學生情況表進行學號、姓名、性別、專業和入學成績的查詢,結果按入學成績欄位從高到低排序,若入學成績相同則按專業升序排列。

5、接著在stu資料庫中查詢所有學生的學號、姓名、性別和年齡。

6、最後在stu資料庫中查詢所有課程的課程號、課程名和學時,要求將所有課程的學時數都加10,查詢結果顯示「增加後的學時數」,如下圖所示就完成了。

2樓:曌非曌

select 學號, 課程號 , 成績 from 表a ( select 課程號 ,max(成績) as mcj from 表a group by 課程號) b where 表a課程號=b.課程號 and 表a.成績 =b.mcj

3樓:擾龍星劍

select t1.學號,t1.課程號,t1.成績from table t1

where t1.成績 = (

select max(t2.成績)

from table t2

where t2.課程號 = t1.課程號group by t2.課程號)

4樓:

select 學號,課程號,max(成績) from 表

group by 學號,課程號

sql查詢每門課程最高分學生的學號,課程號,成績

5樓:匿名使用者

select t1.學號,t1.課程號,t1.成績from table t1

where t1.成績 = (

select max(t2.成績)

from table t2

where t2.課程號 = t1.課程號group by t2.課程號)

6樓:匿名使用者

首先你得告訴我們你有幾張表,表裡都有什麼列,然後我們才能決定怎麼查,是連線查詢還是你的所有資料都在一個表裡。在此我先給出都在一個表的情況:select 學號,課程號,成績 from 表名 where 表主鍵 in(select 表主鍵 from 表名 where 學分=max(學分) group by 課程號)

7樓:清茶稀飯

select

學號,課程號,成績,max(分數)

from tablename

group by 學號,課程號,成績

用sql語言查詢每門課程得最高分的學生學號,課程號,成績.查詢結果按課程號升序排列

sqlserver查詢各系各科成績最高分的學生的學號,姓名,系名,課程名稱,成績?

8樓:sql的藝術

select

a.sno 學號,a.sname 姓名,a.sdept 系名,c.cname 課程名稱,b.maxgrade 成績

from

student a

inner join (select cno,max(sno) sno,max(grade) maxgrade from sc group by cno) b on a.sno=b.sno

inner join course c on b.con=c.cno

9樓:匿名使用者

select student.sno,student.sname,student.sdept,

course.cname,t.maxgrade from

student,course,

(select  s.sno,c.sdept,s.cno,c.maxgrade

from sc s,student st,

(select a.sdept,b.cno,max(b.grade) as maxgrade

from student a,sc b where a.sno=b.sno

group by a.sdept,b.cno) c

where s.sno=st.sno and st.sdept=c.sdept and

s.grade=c.maxgrade) t where student.sno=t.sno

and course.cno=t.cno order by course.cname,student.sdept;

上述語句已經測試通過。**思路是:

學生表與成績表基於學號進行連線獲取每個學號所在系名,然後用院系和課程號對成績表分組彙總,求得每個院系、每個課程的最高得分(結果集c,含系名、課程號和最高分)。然後用結果集c再次與成績表、學生表進行比對,篩選出獲得每個系、每個課程的最高分的學號幷包含課程號和系名(結果集t)。最後t通過連線獲取學生表中的學生姓名、課程表中的課程名完成最後輸出。

10樓:me孤魂

因為不知道3個表的具體結果只能推測3個表的關聯情況學生表student 的學號sno 和成績表sc 的學號sno關聯課程表course的課程cno和成績表sc 的課程cno關聯首先獲得sc表中每門課程的最高成績,然後跟sc關聯獲得其他資訊,在分別去學生表,課程表關聯,獲得具體的資訊

語句如下

select a.sno,c.sname,c.

sdept,d.cno,b.grade from sc a,(select cno,max(grade) grade from sc group by cno) b,student c,coursed d

where a.cno=b.grade

and a.sno=c.sno

and a.cno=d.cno

sql查詢每門課程的最高分 從三表中查詢每門課程的最高分學生,顯示學號,姓名,課程名稱和成績四列。 10

11樓:侯佳輝

三張表關聯,再按課程進行分組,取每門課程的最高分,顯示你需要的四列資料就好了。把表結構貼一下,可以給你寫一下。

12樓:陽光的雷咩咩

至少你要把相關所有表的欄位都貼出來

查詢每門課成績最高分的同學的sql語句,輸出課程名,姓名,學號,分數。表的結構如下。寫出完整的sql語句

13樓:匿名使用者

首先三表連線,然後select max(分數),姓名,學號, 課程 from 連線表 group by 姓名,學號, 課程即可。

14樓:

select cname,sname,student.sno,grade

from student join sc on student.sno=sc.sno

join course on course.cno=sc.cnowhere grade=(select max(grade)from sc

where cno=course.cno )

15樓:匿名使用者

select cname,sname,sc.sno,grade

from student,sc,course

where student.sno =sc.sno and sc.

cno =course.cno and grade=(select max(grade) from sc where sc.cno =course.

cno )

16樓:一人離散

select cname,sname,student.sno,sc1.grade

from student join sc as sc1 on student.sno=sc1.sno

join course on sc1.cno=course.cnowhere not exists(

select * from sc as sc2where sc1.cno=sc2.cno and sc1.

grade

order by sc1.cno

sqlserver查詢各系各科成績最高分的學生的學號,姓名

select a.sno 學號,a.sname 姓名,a.sdept 系名,c.cname 課程名稱,b.maxgrade 成績 from student a inner join select cno,max sno sno,max grade maxgrade from sc group by ...

sql語句求每門課程的成績都在80分以上的學生的學號

select sno from student where sno not in select sno from sc where grade 80 select distinct sno from sc where cno in select cno from course where cteac...

關於電腦卡的問題,最高分請教高人

如果排除系統問題,那就是記憶體問題,現在一代的記憶體水貨很多,如果他換的新記憶體,你就要小心了,換舊記憶體的話,風險也大,用過那麼久的記憶體條哪個也不敢保證沒有問題的。再說你的電腦很舊了,而且燒了板子,其它配件 如硬碟等 會不會也有輕微的損壞,就不得而知了。你說找不到cd rom,是不是那個人沒有把...