華為java面試題1.doc_第1頁
華為java面試題1.doc_第2頁
華為java面試題1.doc_第3頁
華為java面試題1.doc_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

Student(S#,Sname,Sage,Ssex) 學(xué)生表Course(C#,Cname,T#) 課程表SC(S#,C#,score) 成績表Teacher(T#,Tname) 教師表 問題:1、查詢“001”課程比“002”課程成績高的所有學(xué)生的學(xué)號(hào);select a.S#from (select s#,score from SC where C#=001) a,(select s#,score from SC where C#=002) bwhere a.scoreb.score and a.s#=b.s#; 2、查詢平均成績大于60分的同學(xué)的學(xué)號(hào)和平均成績;select S#,avg(score)from scgroup by S# having avg(score) 60; 3、查詢所有同學(xué)的學(xué)號(hào)、姓名、選課數(shù)、總成績;select Student.S#,Student.Sname,count(SC.C#),sum(score)from Student left Outer join SC on Student.S#=SC.S#group by Student.S#,Sname 4、查詢姓“李”的老師的個(gè)數(shù);select count(distinct(Tname)from Teacherwhere Tname like 李%; 5、查詢沒學(xué)過“葉平”老師課的同學(xué)的學(xué)號(hào)、姓名;select Student.S#,Student.Snamefrom Studentwhere S# not in (select distinct( SC.S#) from SC,Course,Teacher where SC.C#=Course.C# and Teacher.T#=Course.T# and Teacher.Tname=葉平); 6、查詢學(xué)過“001”并且也學(xué)過編號(hào)“002”課程的同學(xué)的學(xué)號(hào)、姓名;select Student.S#,Student.Snamefrom Student,SCwhere Student.S#=SC.S# and SC.C#=001and exists( Select * from SC as SC_2 where SC_2.S#=SC.S# and SC_2.C#=002);7、查詢學(xué)過“葉平”老師所教的所有課的同學(xué)的學(xué)號(hào)、姓名;select S#,Snamefrom Studentwhere S# in(select S#from SC ,Course ,Teacherwhere SC.C#=Course.C# and Teacher.T#=Course.T# and Teacher.Tname=葉平 group by S# having count(SC.C#)=(select count(C#) from Course,Teacher where Teacher.T#=Course.T# and Tname=葉平); 8、查詢所有課程成績小于60分的同學(xué)的學(xué)號(hào)、姓名;select S#,Snamefrom Studentwhere S# not in (select Student.S# from Student,SC where S.S#=SC.S# and score60); 9、查詢沒有學(xué)全所有課的同學(xué)的學(xué)號(hào)、姓名;select Student.S#,Student.Snamefrom Student,SCwhere Student.S#=SC.S#group by Student.S#,Student.Sname having count(C#) T2.平均成績) 名次, S# 學(xué)生學(xué)號(hào),平均成績FROM (SELECT S#,AVG(score) 平均成績 FROM SC GROUP BY S# ) T2ORDER BY 平均成績 desc;14、查詢各科成績前三名的記錄:(不考慮成績并列情況)SELECT t1.S# as 學(xué)生ID,t1.C# as 課程ID,Score as 分?jǐn)?shù)FROM SC t1WHERE score IN (SELECT TOP 3 scoreFROM SCWHERE t1.C#= C#ORDER BY score DESC)ORDER BY t1.C#; 15、查詢每門功成績最好的前兩名SELECT t1.S# as 學(xué)生ID,t1.C# as 課程ID,Score as 分?jǐn)?shù)FROM SC t1WHERE score IN (SELECT TOP 2 scoreFROM SCWHERE t1.C#= C#ORDER BY score DESC )ORDER BY t1.C#;補(bǔ)充:已經(jīng)知道原表year salary2000 10002001 20002002 30002003 4000解:select b.year,sum(a.salary)from salary a,salary bwhere a.year(select max(ID) from (select top 30 ID from A order

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論