java高頻率基礎(chǔ)面試題——(九)

發(fā)布時間:2024-03-04
想要成為一名合格的java后端開發(fā)者,數(shù)據(jù)庫知識必不可少,對數(shù)據(jù)庫的掌握熟悉度的考察也是對這個人是否有扎實基本功的考察。
(更多相關(guān)面試題推薦:java面試題及答案)
特別對于初級開發(fā)者,面試可能不會去問框架相關(guān)知識,但是絕對不會不去考察數(shù)據(jù)庫知識,這里收集一些常見類型的sql語句,無論對于平常開發(fā)還是準備面試,都會有助益。
基本表結(jié)構(gòu):
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) bwhere a.score>b.score and a.sno=b.sno102,查詢平均成績大于60分的同學的學號和平均成績
select a.sno as "學號", avg(a.score) as "平均成績" from(select sno,score from sc) a group by sno having avg(a.score)>60103,查詢所有同學的學號、姓名、選課數(shù)、總成績
select a.sno as 學號, b.sname as 姓名,count(a.cno) as 選課數(shù), sum(a.score) as 總成績from sc a, student bwhere a.sno = b.snogroup by a.sno, b.sname或者:
selectstudent.sno as 學號, student.sname as 姓名, count(sc.cno) as 選課數(shù), sum(score) as 總成績from student left outer join sc on student.sno = sc.snogroup by student.sno, sname104,查詢姓“張”的老師的個數(shù)
selectcount(distinct(tname)) from teacher where tname like '張%%u2018或者:
select tname as "姓名", count(distinct(tname)) as "人數(shù)" from teacher where tname like'張%'group by tname105,查詢沒學過“張三”老師課的同學的學號、姓名
select student.sno,student.sname from studentwhere sno not in (select distinct(sc.sno) from sc,course,teacherwhere sc.cno=course.cno and teacher.tno=course.tno and teacher.tname='張三')(推薦學習:java課程)
106,查詢同時學過課程1和課程2的同學的學號、姓名
select sno, sname from studentwhere 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 cwhere 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=1and 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 bwhere 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 = '李四') ewhere a.sno = b.sno and b.cno = e.cno108,查詢課程編號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) cwhere b.score > c.score and b.sno = c.sno and a.sno = b.sno109,查詢所有課程成績小于60分的同學的學號、姓名
select sno,sname from studentwhere sno not in (select distinct sno from sc where score > 60)110,查詢至少有一門課程與學號為1的同學所學課程相同的同學的學號和姓名
select distinct a.sno, a.snamefrom student a, sc bwhere a.sno <> 1 and a.sno=b.sno andb.cno in (select cno from sc where sno = 1)或者:
select s.sno,s.sname from student s,(select sc.sno from scwhere sc.cno in (select sc1.cno from sc sc1 where sc1.sno=1)and sc.sno<>1group by sc.sno)r1where r1.sno=s.sno相關(guān)推薦:java入門教程
上一個:云南省勐海縣茶業(yè)簡述(第六話)
下一個:finder輕觸開關(guān)的注意事項

wp 日歷 怎么刪除,怎么關(guān)掉wp 屏保天氣就是日歷上的
xmind怎么再建一個主題(xmind創(chuàng)建子主題快捷鍵)
電話黑明單在哪里看出來(電話里的黑名單在哪里)
魔星鉆和莫桑鉆哪個好 比利時魔星鉆和莫桑石的區(qū)別
廚房吊頂裝修也有風水禁忌
有期徒刑最多多少年
喝茶有哪3種生津感受?到底
維修瑞士huba編碼器維修
云雞農(nóng)場怎么看不到了(云雞農(nóng)場怎么兌換雞蛋)
繁殖豬群高產(chǎn)的管理措施(二)
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos