中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

數據庫相關面試題有哪些

發布時間:2022-01-05 15:04:03 來源:億速云 閱讀:103 作者:iii 欄目:大數據

這篇文章主要介紹“數據庫相關面試題有哪些”,在日常操作中,相信很多人在數據庫相關面試題有哪些問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”數據庫相關面試題有哪些”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

基本表結構:

        student(sno,sname,sage,ssex)學生表
        course(cno,cname,tno) 課程表
        sc(sno,cno,score) 成績表

        teacher(tno,tname) 教師表

101,查詢課程1的成績比課程2的成績高的所有學生的學號
select a.sno from
(select sno,score from sc where cno=1) a,
(select sno,score from sc where cno=2) b
where a.score>b.score and a.sno=b.sno

102,查詢平均成績大于60分的同學的學號和平均成績
select a.sno as "學號", avg(a.score) as "平均成績" 
from
(select sno,score from sc) a 
group by sno having avg(a.score)>60

103,查詢所有同學的學號、姓名、選課數、總成績
select a.sno as 學號, b.sname as 姓名,
count(a.cno) as 選課數, sum(a.score) as 總成績
from sc a, student b
where a.sno = b.sno
group by a.sno, b.sname

或者:

selectstudent.sno as 學號, student.sname as 姓名,
 count(sc.cno) as 選課數, sum(score) as 總成績
from student left Outer join sc on student.sno = sc.sno
group by student.sno, sname


104,查詢姓“張”的老師的個數

selectcount(distinct(tname)) from teacher where tname like '張%‘
或者:
select tname as "姓名", count(distinct(tname)) as "人數" 
from teacher 
where tname like'張%'
group by tname

105,查詢沒學過“張三”老師課的同學的學號、姓名
select student.sno,student.sname from student
where sno not in (select distinct(sc.sno) from sc,course,teacher
where sc.cno=course.cno and teacher.tno=course.tno and teacher.tname='張三')

106,查詢同時學過課程1和課程2的同學的學號、姓名
select sno, sname from student
where sno in (select sno from sc where sc.cno = 1)
and sno in (select sno from sc where sc.cno = 2)
或者:

selectc.sno, c.sname from
(select sno from sc where sc.cno = 1) a,
(select sno from sc where sc.cno = 2) b,
student c
where a.sno = b.sno and a.sno = c.sno
或者:

select student.sno,student.sname from student,sc where student.sno=sc.sno and sc.cno=1
and exists( select * from sc as sc_2 where sc_2.sno=sc.sno and sc_2.cno=2)

107,查詢學過“李四”老師所教所有課程的所有同學的學號、姓名
select a.sno, a.sname from student a, sc b
where a.sno = b.sno and b.cno in
(select c.cno from course c, teacher d where c.tno = d.tno and d.tname = '李四')

或者:

select a.sno, a.sname from student a, sc b,
(select c.cno from course c, teacher d where c.tno = d.tno and d.tname = '李四') e
where a.sno = b.sno and b.cno = e.cno

108,查詢課程編號1的成績比課程編號2的成績高的所有同學的學號、姓名
select a.sno, a.sname from student a,
(select sno, score from sc where cno = 1) b,
(select sno, score from sc where cno = 2) c
where b.score > c.score and b.sno = c.sno and a.sno = b.sno

109,查詢所有課程成績小于60分的同學的學號、姓名
select sno,sname from student
where sno not in (select distinct sno from sc where score > 60)

110,查詢至少有一門課程與學號為1的同學所學課程相同的同學的學號和姓名
select distinct a.sno, a.sname
from student a, sc b
where a.sno <> 1 and a.sno=b.sno and
b.cno in (select cno from sc where sno = 1)

或者:

select s.sno,s.sname 
from student s,
(select sc.sno 
from sc
where sc.cno in (select sc1.cno from sc sc1 where sc1.sno=1)and sc.sno<>1
group by sc.sno)r1
where r1.sno=s.sno

到此,關于“數據庫相關面試題有哪些”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

赣州市| 灯塔市| 满洲里市| 邯郸市| 永川市| 邵东县| 德江县| 苍溪县| 郧西县| 黑山县| 景洪市| 承德市| 武陟县| 博白县| 伊通| 六安市| 上思县| 教育| 石台县| 奉节县| 个旧市| 左云县| 侯马市| 涟水县| 开封市| 邹城市| 长子县| 合阳县| 涟源市| 星子县| 锦州市| 彭州市| 库伦旗| 清水河县| 花莲县| 冕宁县| 新津县| 石林| 大方县| 育儿| 开远市|