免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
試驗(yàn)七 Sql 查詢語句目的: 掌握 Select 查詢語句。一 單表1查詢年齡在19至21歲之間的女生的學(xué)號(hào),姓名,年齡,按年齡從大到小排列。select sno,sname,sage from studentwhere sage between 19 and 21 and ssex=女 order by sage desc2查詢姓名中第戎2個(gè)字為“明”字的學(xué)生學(xué)號(hào)、性別。select sname ,ssex from student where sname like _明%3查詢 1001課程沒有成績的學(xué)生學(xué)號(hào)、課程號(hào)select sno,cno from sc where grade is null and cno=10014查詢JSJ 、SX、WL 系的學(xué)生學(xué)號(hào),姓名,結(jié)果按系及學(xué)號(hào)排列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é)生共分布在那幾個(gè)系中。(distinct)select distinct sdept from student7查詢0001號(hào)學(xué)生1001,1002課程的成績。 Select cno from sc where sno=0001 and (cno=1001 or cno=1002)二 統(tǒng)計(jì)1查詢姓名中有“明”字的學(xué)生人數(shù)。select count(*) from student where sname like %明%2計(jì)算JSJ系的平均年齡及最大年齡。 Select avg(sage) , max(sage) from student Where sdept=JSJ3計(jì)算每一門課的總分、平均分,最高分、最低分,按平均分由高到低排列 select cno,sum(grade),avg(grade),max(grade),min(grade) from sc group by cno order by avg(grade) desc4 計(jì)算 1001,1002 課程的平均分。Select cno , avg(grade) from sc where cno in (1001,1002)Group by cno5 查詢平均分大于80分的學(xué)生學(xué)號(hào)及平均分select sc.sno , avg(grade) from scgroup by sc.snohaving avg(grade)806 統(tǒng)計(jì)選修課程超過 2 門的學(xué)生學(xué)號(hào) select sno from sc group by sno having count(*)27 統(tǒng)計(jì)有10位成績大于85分以上的課程號(hào)。Select cno from scwhere grade85group by cno having count(*) =108 統(tǒng)計(jì)平均分不及格的學(xué)生學(xué)號(hào)select sno from sc group by sno having avg(grade)609 統(tǒng)計(jì)有大于兩門課不及格的學(xué)生學(xué)號(hào)select sno from sc where grade2三 連接1查詢 JSJ 系的學(xué)生選修的課程號(hào) 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é)號(hào)及成績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é)號(hào),姓名,平均分。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é)號(hào)、姓名、課程號(hào)、成績。(一門課程也沒有選修的男學(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é)號(hào)(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é)號(hào)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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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ǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 物品價(jià)格歧視課件
- 2026年四川單招專升本銜接備考經(jīng)典題含答案職業(yè)本科方向
- 2026年貴州單招文化素質(zhì)語文作文高分模板素材題庫含答案含經(jīng)典題例文
- 2026年寧夏單招護(hù)理專業(yè)中職生技能經(jīng)典題含答案含生命體征監(jiān)測(cè)
- 2026年貴州單招職業(yè)適應(yīng)性測(cè)試時(shí)政經(jīng)典題集含答案
- 2026年上海單招計(jì)算機(jī)類軟件技術(shù)專業(yè)技能實(shí)操經(jīng)典題含答案含編程基礎(chǔ)
- 2026年云南單招汽修專業(yè)技能實(shí)操模擬題庫含答案
- 校園霸凌防治工作考核評(píng)價(jià)機(jī)制
- 2026年江西中職生單招專業(yè)技能對(duì)口沖刺卷含答案原專業(yè)11適配
- 2026年青島普高生單招職業(yè)適應(yīng)性測(cè)試零基礎(chǔ)通關(guān)題庫含答案
- 2025下半年貴州遵義市市直事業(yè)單位選調(diào)56人筆試考試備考題庫及答案解析
- 2025年天津大學(xué)管理崗位集中招聘15人備考題庫及完整答案詳解1套
- 《登泰山記》課件+2025-2026學(xué)年統(tǒng)編版高一語文必修上冊(cè)
- 臨床醫(yī)學(xué)暈厥課件
- 中職汽車維修教學(xué)中數(shù)字化技術(shù)應(yīng)用的實(shí)踐課題報(bào)告教學(xué)研究課題報(bào)告
- 《儲(chǔ)能技術(shù)》課件-2.4 抽水蓄能電站發(fā)電電動(dòng)機(jī)
- 2025年事業(yè)單位工勤人員高級(jí)工圖書倉儲(chǔ)員考試試題附答案
- 2025年護(hù)理指南范文
- 部編人教版二年級(jí)下冊(cè)小學(xué)語文全冊(cè)教案(教學(xué)設(shè)計(jì))(新課標(biāo)核心素養(yǎng)教案)
- 鍋爐房煙、風(fēng)道制作安裝施工方案
- 新版糖尿病看圖對(duì)話新
評(píng)論
0/150
提交評(píng)論