



免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
試驗(yàn)七 Sql 查詢語句目的: 掌握 Select 查詢語句。一 單表1查詢年齡在19至21歲之間的女生的學(xué)號,姓名,年齡,按年齡從大到小排列。select sno,sname,sage from studentwhere sage between 19 and 21 and ssex=女 order by sage desc2查詢姓名中第戎2個字為“明”字的學(xué)生學(xué)號、性別。select sname ,ssex from student where sname like _明%3查詢 1001課程沒有成績的學(xué)生學(xué)號、課程號select sno,cno from sc where grade is null and cno=10014查詢JSJ 、SX、WL 系的學(xué)生學(xué)號,姓名,結(jié)果按系及學(xué)號排列select sno,sname from student where sdept in (JSJ,SX,WL)order by sdept,sno5按10分制查詢學(xué)生的sno,cno,10分制成績 (1-10分 為1 ,11-20分為2 ,30-39分為3,。90-100為10)select sno , cno , grade/10.0+1 as level from sc6查詢 student 表中的學(xué)生共分布在那幾個系中。(distinct)select distinct sdept from student7查詢0001號學(xué)生1001,1002課程的成績。 Select cno from sc where sno=0001 and (cno=1001 or cno=1002)二 統(tǒng)計1查詢姓名中有“明”字的學(xué)生人數(shù)。select count(*) from student where sname like %明%2計算JSJ系的平均年齡及最大年齡。 Select avg(sage) , max(sage) from student Where sdept=JSJ3計算每一門課的總分、平均分,最高分、最低分,按平均分由高到低排列 select cno,sum(grade),avg(grade),max(grade),min(grade) from sc group by cno order by avg(grade) desc4 計算 1001,1002 課程的平均分。Select cno , avg(grade) from sc where cno in (1001,1002)Group by cno5 查詢平均分大于80分的學(xué)生學(xué)號及平均分select sc.sno , avg(grade) from scgroup by sc.snohaving avg(grade)806 統(tǒng)計選修課程超過 2 門的學(xué)生學(xué)號 select sno from sc group by sno having count(*)27 統(tǒng)計有10位成績大于85分以上的課程號。Select cno from scwhere grade85group by cno having count(*) =108 統(tǒng)計平均分不及格的學(xué)生學(xué)號select sno from sc group by sno having avg(grade)609 統(tǒng)計有大于兩門課不及格的學(xué)生學(xué)號select sno from sc where grade2三 連接1查詢 JSJ 系的學(xué)生選修的課程號 select cno from student,sc where student.sno=sc.sno and sdept=JSJ2查詢選修1002 課程的學(xué)生的學(xué)生姓名 (不用嵌套及嵌套2種方法)a: select sname from student,sc where student.sno = sc.sno and cno=1002b: select sname from student where sno in (select sno from sc where cno=1002)3查詢數(shù)據(jù)庫原理不及格的學(xué)生學(xué)號及成績select sno,grade from sc ,coursewhere o=o and cname=數(shù)據(jù)庫原理4查詢選修“數(shù)據(jù)庫原理”課且成績 80 以上的學(xué)生姓名(不用嵌套及嵌套2種方法)a: select sname from student , sc , course where student.sno=sc.sno and o = o andgrade80 and cname=數(shù)據(jù)庫原理b: select sname from student where sno in ( select sno from sc where grade80 and cno in ( select cno from course where cname=數(shù)據(jù)庫原理) )5查詢平均分不及格的學(xué)生的學(xué)號,姓名,平均分。select sno, max(sname) , avg(grade) as avggrade from sc , studentwhere student.sno=sc.snogroup by student.snohaving avg(grade) 75)B: Select max(sname ) from sc,student where student.sno=sc.sno and Ssex=女 Group by student.sno having avg(grade)757查詢男學(xué)生學(xué)號、姓名、課程號、成績。(一門課程也沒有選修的男學(xué)生也要列出,不能遺漏)select student.sno,sname,cno,grade from student left join sc ON student.sno=sc.sno and ssex=男四 嵌套、相關(guān)及其他1 查詢平均分不及格的學(xué)生人數(shù)select count(*) from student where sno in (select sno from sc group by sno having avg(grade)=all ( select avg(grade) from sc group by sno )*4 查詢沒有選修1001,1002課程的學(xué)生姓名。Select sname from student where not exists ( Select * from course where cno in (1001,1002) and Not exists ( select * from sc where sno=student.sno and cno=o ) )5 查詢1002課程第一名的學(xué)生學(xué)號(2種方法)a: select top 1 sno from sc cno=1002 order by grade descb: select sno from sc where cno=1002 andgrade =all (select grade from sc where cno=1002)6 查詢平均分前三名的學(xué)生學(xué)號select top 3 sno from sc group by sno order by avg(grade) desc7 查詢 JSJ 系的學(xué)生與年齡不大于19歲的學(xué)生的差集a: select * from student where sdept=JSJ and sage19b: select * from student where sdept=JSJ except select * from student where sage90unionselect sno,sname from student where sno in ( select sno from sc group by sno
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025商場店鋪?zhàn)赓U合同標(biāo)準(zhǔn)范本
- 2025工程分包合同標(biāo)準(zhǔn)范本
- 2025設(shè)備采購合同示范文本GF
- 2025商業(yè)銀行保安服務(wù)合同
- 養(yǎng)殖魚塘轉(zhuǎn)租合同樣本
- 材料采購議標(biāo)方案范本
- 媒體產(chǎn)業(yè)品牌宣傳方案計劃
- 借貸合同 投資合同樣本
- 出電子合同樣本
- 農(nóng)村房屋爭議合同標(biāo)準(zhǔn)文本
- 房地產(chǎn)行業(yè)未來走勢與機(jī)遇分析
- 2025年中國色度儀行業(yè)發(fā)展運(yùn)行現(xiàn)狀及投資策略研究報告
- 2025年淄博市光明電力服務(wù)有限責(zé)任公司招聘筆試參考題庫含答案解析
- 河北省部分重點(diǎn)中學(xué)2024-2025學(xué)年高三下學(xué)期3月聯(lián)合測評(T8聯(lián)考)化學(xué)試題(含答案)
- 住宅老舊電梯更新改造工作指南匯報- 中國電梯協(xié)會
- 物流企業(yè)防汛演練方案與流程
- 2024年重慶聯(lián)合產(chǎn)權(quán)交易所集團(tuán)股份有限公司招聘考試真題
- 2024年陜西省縣以下醫(yī)療衛(wèi)生機(jī)構(gòu)定向招聘考試真題
- 鄰里間的溫暖
- 廣西柳州銀行招聘考試真題2024
- DB34T 5102-2025巢湖流域農(nóng)田面源污染防控技術(shù)指南
評論
0/150
提交評論