用SQL語句查詢每個學生選修的課程名及其成績

2021-03-04 02:04:37 字數 4335 閱讀 8251

1樓:消逝的風

select 姓名,課程名,成績 from (課程名所在的表名 c join 成績所在的表名 s on c.課程號=s.課程號) join 學生資訊表 on s.

學號=學生資訊表.學號 ;

具體的例子:

select sname,**ame,grade from student st left join(score s left join course c on s.**o=c.**o)

on st.sno=s.sno;

怎麼用sql語句查詢每個學生選修的課程名及其成績?

2樓:消逝的風

select 姓名,課程名,成績 from (課程名所在的表名 c join 成績所在的表名 s on c.課程號=s.課程號) join 學生資訊表 on s.

學號=學生資訊表.學號 ;

具體的例子:

select sname,**ame,grade from student st left join(score s left join course c on s.**o=c.**o)

on st.sno=s.sno;

3樓:趙星宇

查詢選修了全部課程的學生姓名

:student 是學生表  course 是選課表  sc 是課程表

select sname

from student

where not exists

(select *

from course

where not exists

(select *

from sc

where sno =student.snoand **o=course.**o)

查詢每個學生選修的課程名及其成績?用sql語句

4樓:發生等將發生

表結構,沒有表結構語句沒法出來

5樓:萇茂雀涵涵

select

姓名bai,課程名,成績

from

(課程du名所zhi

在的表名

cjoin

成績所dao在的表名son

c.課程號=s.課程號)

join

學生版信權息表

ons.學號=學生資訊表.學號

;具體的例子:

select

sname,**ame,grade

from

student

stleft

join(score

sleft

join

coursecon

s.**o=c.**o)

onst.sno=s.sno;

mysql 怎麼用sql語句寫:按學號列出每個學生所選修課程中最高分的課程名稱及其分數

6樓:黃鶯清吟

select 課程名

,a.最高bai分du from

(select max(分數zhi)最高dao分,學號回 from 表名答 group by 學號 )a,表名 bwhere b.學號=a.學號 and b.

分數=a.最高分

7樓:匿名使用者

select max(分數),名稱 from user group by id

用sql語句查詢所有學員(包括沒有選課的學員)的選課情況 (即選修的課程名和成績),沒有選課的學員相關

8樓:匿名使用者

select s.sname, c.**ame, sc.scgrade

from s left outer join sc on( s.sno = sc.sno )

left outer join c on ( c.**o = sc.**o )

用sql語句寫出只選修一門的學生的學號、課程名、成績。

9樓:我不發財

select 學號、課程名、成績 from 成績表 where 學號 in(

select 學號 from 成績表 group by 學號 having count(課程名)=1)

好像沒錯誤

10樓:匿名使用者

如下:select *

from 表名

where 學號 in

(select 學號

from 表名

group by 學號

having count(課程名)=1);

11樓:匿名使用者

select 學號,課程名,成績 from 成績表 having count(課程名)=1

12樓:匿名使用者

select 學號,課程名,成績 from 成績表 a,(select 學號,count(*) as num from 成績表 group by 學號) b where b.num = 1 and b.學號 = a.學號

sql語言1.查詢每個學生及其選修課程的情況2、查詢所有年齡小於18周歲的女生的學號和姓名

13樓:匿名使用者

(1) select t.sname,c.cpno fromstudent t

left join sc s (s.sno=t.sno)left join course c (c.

**o=s.**o)(2) select t.sno,t.

sname from student t

where t.s***='女' and t.sage <18不行了在找我,可以密我**。

14樓:匿名使用者

1 select student.sno, sc.**ofrom student,sc

where student.sno = sc.**o;

意思就是查詢每個學生的情況,且列出相應的選修情況2 select student.s***, student.sage

from student

where student.sage<18 and student.s***=2;

's***=2意思就是等於女的意思,一般在這個表裡s***字段設定為數字型1為男2為女,也可以設定成字元型,但不如數字型使用方便

15樓:真愛的胸懷

select sno,sname,from student where (sage<18 and s***='女')

以上是第二個語句的答案 ,第乙個語句有歧義

16樓:匿名使用者

select a.sno,a.sname,b.**amefrom student a,cours b,sc cwhere a.sno=c.sno

and b.**o=c.**o

group by a.sno,a.sname,b.**ameselect sno,sname from studentwhere s***='女' and sage<18

sql 查詢每個學生的基本資訊以及所選修的課程情況

17樓:匿名使用者

很簡單bai的關聯查詢,sql如下du

:select a.sn,a.sd,a.***,a.sb,c.**,c.teacher,b.grade from s as a

join sc as b

on a.sno=b.sno

join c as c

on b.**o=c.**o

如上是查詢到zhi所有dao學生的基本資訊和選課版情況還有成績。權

資料庫sql語句中 查詢選修了全部課程的學生的學號和姓名 理解

18樓:風嘯無名

沒有資料庫難以具體說明,

總的來說,就是乙個多表查詢包括學生基本資訊表、課程資訊表、成績表等,學號為主鍵,查詢姓名和課程、分數等資訊,總分用sum算。

1 。 exists 子查詢找到的提交

not exists 子查詢中 找不到的提交說明:不要去翻譯為存在和不存在,把腦袋搞暈。

2 。 建立程式迴圈的概念,這是乙個動態的查詢過程。如 for迴圈 。

3 。 exists執行的流程exists首先執行外層查詢,再執行記憶體查詢,與in相反。 流程為首先取出外層中的第一元組, 再執行內層查詢,將外層表的第一元組代入,若內層查詢為真,即有結果時。

返回外層表中的第一元 組,接著取出第二元組,執行相同的演算法。一直到掃瞄完外層整表 。

用sql語句查詢男學生的學號姓名,年齡

select 列名 學號 列名 姓名 列名 年齡 from table name where 列名 性別 男性 select id,name,age from student where 男 求解sql。設有學生表s 學號,姓名,性別,年齡 查詢所有年齡小於等於20歲的男同學。並按年齡生成新列 你好...

如何使用sql編寫查詢語句用於查詢學生的各科成績

declare sql varchar 8000 select sql select a.mname as 學生姓名 select sql sql sum case c.fname when fname then b.score else null end as fname from f selec...

用SQL語句查詢每門成績都大於80的學生姓名?新手求教

select name from stu t1 where not exists select 1 from tab where name t1.name and fs 80 select distinct a.namefrom select name,km,fs,count over partit...