Java面試中出現(xiàn)率極高的數(shù)據(jù)庫(kù)查詢題有哪些

這篇文章將為大家詳細(xì)講解有關(guān)Java面試中出現(xiàn)率極高的數(shù)據(jù)庫(kù)查詢題有哪些,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

十多年的駐馬店網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整駐馬店建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“駐馬店網(wǎng)站設(shè)計(jì)”,“駐馬店網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

基本表結(jié)構(gòu):

teacher(tno,tname) 教師表

student(sno,sname,sage,ssex)學(xué)生表

course(cno,cname,tno) 課程表

sc(sno,cno,score) 成績(jī)表

NO.1查詢課程1的成績(jī)比課程2的成績(jī)高的所有學(xué)生的學(xué)號(hào)

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.sno

NO.2查詢平均成績(jī)大于60分的同學(xué)的學(xué)號(hào)和平均成績(jī)

select a.sno as "學(xué)號(hào)", avg(a.score) as "平均成績(jī)" from(select sno,score from sc) a group by sno having avg(a.score)>60

NO.2查詢所有同學(xué)的學(xué)號(hào)、姓名、選課數(shù)、總成績(jī)

select a.sno as 學(xué)號(hào), b.sname as 姓名,count(a.cno) as 選課數(shù), sum(a.score) as 總成績(jī)from sc a, student bwhere a.sno = b.snogroup by a.sno, b.sname

或者:

selectstudent.sno as 學(xué)號(hào), student.sname as 姓名, count(sc.cno) as 選課數(shù), sum(score) as 總成績(jī)from student left Outer join sc on student.sno = sc.snogroup by student.sno, sname

NO.3查詢姓“張”的老師的個(gè)數(shù)

selectcount(distinct(tname)) from teacher where tname like '張%‘

或者:

select tname as "姓名", count(distinct(tname)) as "人數(shù)" from teacher where tname like'張%'group by tname

NO.4查詢沒(méi)學(xué)過(guò)“張三”老師課的同學(xué)的學(xué)號(hào)、姓名

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='張三')

NO.5查詢同時(shí)學(xué)過(guò)課程1和課程2的同學(xué)的學(xué)號(hào)、姓名

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)

NO.6查詢學(xué)過(guò)“李四”老師所教所有課程的所有同學(xué)的學(xué)號(hào)、姓名

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.cno

NO.7查詢課程編號(hào)1的成績(jī)比課程編號(hào)2的成績(jī)高的所有同學(xué)的學(xué)號(hào)、姓名

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

NO.8查詢所有課程成績(jī)小于60分的同學(xué)的學(xué)號(hào)、姓名

select sno,sname from studentwhere sno not in (select distinct sno from sc where score > 60)

NO.9查詢至少有一門(mén)課程與學(xué)號(hào)為1的同學(xué)所學(xué)課程相同的同學(xué)的學(xué)號(hào)和姓名

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面試中出現(xiàn)率極高的數(shù)據(jù)庫(kù)查詢題有哪些就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

本文題目:Java面試中出現(xiàn)率極高的數(shù)據(jù)庫(kù)查詢題有哪些
網(wǎng)站鏈接:http://bm7419.com/article12/igepdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司全網(wǎng)營(yíng)銷推廣、移動(dòng)網(wǎng)站建設(shè)、、網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司