



免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
試驗(yàn)七 Sql 查詢(xún)語(yǔ)句目的: 掌握 Select 查詢(xún)語(yǔ)句。一 單表1查詢(xún)年齡在19至21歲之間的女生的學(xué)號(hào),姓名,年齡,按年齡從大到小排列。select sno,sname,sage from studentwhere sage between 19 and 21 and ssex=女 order by sage desc2查詢(xún)姓名中第戎2個(gè)字為“明”字的學(xué)生學(xué)號(hào)、性別。select sname ,ssex from student where sname like _明%3查詢(xún) 1001課程沒(méi)有成績(jī)的學(xué)生學(xué)號(hào)、課程號(hào)select sno,cno from sc where grade is null and cno=10014查詢(xún)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分制查詢(xún)學(xué)生的sno,cno,10分制成績(jī) (1-10分 為1 ,11-20分為2 ,30-39分為3,。90-100為10)select sno , cno , grade/10.0+1 as level from sc6查詢(xún) student 表中的學(xué)生共分布在那幾個(gè)系中。(distinct)select distinct sdept from student7查詢(xún)0001號(hào)學(xué)生1001,1002課程的成績(jī)。 Select cno from sc where sno=0001 and (cno=1001 or cno=1002)二 統(tǒng)計(jì)1查詢(xún)姓名中有“明”字的學(xué)生人數(shù)。select count(*) from student where sname like %明%2計(jì)算JSJ系的平均年齡及最大年齡。 Select avg(sage) , max(sage) from student Where sdept=JSJ3計(jì)算每一門(mén)課的總分、平均分,最高分、最低分,按平均分由高到低排列 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 查詢(xún)平均分大于80分的學(xué)生學(xué)號(hào)及平均分select sc.sno , avg(grade) from scgroup by sc.snohaving avg(grade)806 統(tǒng)計(jì)選修課程超過(guò) 2 門(mén)的學(xué)生學(xué)號(hào) select sno from sc group by sno having count(*)27 統(tǒng)計(jì)有10位成績(jī)大于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ì)有大于兩門(mén)課不及格的學(xué)生學(xué)號(hào)select sno from sc where grade2三 連接1查詢(xún) JSJ 系的學(xué)生選修的課程號(hào) select cno from student,sc where student.sno=sc.sno and sdept=JSJ2查詢(xún)選修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查詢(xún)數(shù)據(jù)庫(kù)原理不及格的學(xué)生學(xué)號(hào)及成績(jī)select sno,grade from sc ,coursewhere o=o and cname=數(shù)據(jù)庫(kù)原理4查詢(xún)選修“數(shù)據(jù)庫(kù)原理”課且成績(jī) 80 以上的學(xué)生姓名(不用嵌套及嵌套2種方法)a: select sname from student , sc , course where student.sno=sc.sno and o = o andgrade80 and cname=數(shù)據(jù)庫(kù)原理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ù)庫(kù)原理) )5查詢(xún)平均分不及格的學(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查詢(xún)男學(xué)生學(xué)號(hào)、姓名、課程號(hào)、成績(jī)。(一門(mén)課程也沒(méi)有選修的男學(xué)生也要列出,不能遺漏)select student.sno,sname,cno,grade from student left join sc ON student.sno=sc.sno and ssex=男四 嵌套、相關(guān)及其他1 查詢(xún)平均分不及格的學(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 查詢(xún)沒(méi)有選修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 查詢(xún)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 查詢(xún)平均分前三名的學(xué)生學(xué)號(hào)select top 3 sno from sc group by sno order by avg(grade) desc7 查詢(xún) 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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 粘膠打包機(jī)企業(yè)數(shù)字化轉(zhuǎn)型與智慧升級(jí)戰(zhàn)略研究報(bào)告
- 彩繪復(fù)制件企業(yè)縣域市場(chǎng)拓展與下沉戰(zhàn)略研究報(bào)告
- 組合軸承企業(yè)縣域市場(chǎng)拓展與下沉戰(zhàn)略研究報(bào)告
- 網(wǎng)絡(luò)分析儀企業(yè)縣域市場(chǎng)拓展與下沉戰(zhàn)略研究報(bào)告
- 制棍機(jī)械企業(yè)縣域市場(chǎng)拓展與下沉戰(zhàn)略研究報(bào)告
- 重水試驗(yàn)反應(yīng)堆及其配套產(chǎn)品戰(zhàn)略市場(chǎng)規(guī)劃報(bào)告
- 2025年曝氣轉(zhuǎn)刷項(xiàng)目合作計(jì)劃書(shū)
- 2025年大功率電源及系統(tǒng)項(xiàng)目合作計(jì)劃書(shū)
- 浙江中醫(yī)藥大學(xué)招聘筆試真題2024
- 2024年貴州民族大學(xué)招聘考試真題
- 2024-2030年中國(guó)汽車(chē)座椅行業(yè)市場(chǎng)發(fā)展分析及競(jìng)爭(zhēng)格局與投資前景研究報(bào)告
- 《暢游海底世界-趣味折紙 》(教學(xué)設(shè)計(jì))-三年級(jí)上冊(cè)勞動(dòng)蘇教版
- 汽車(chē)維修投標(biāo)技術(shù)方案(2篇)
- 2024年江蘇省南通市崇川區(qū)、如皋市九年級(jí)(下)中考一模英語(yǔ)試卷(含詳細(xì)答案解析)
- 機(jī)電系統(tǒng)數(shù)字控制技術(shù)智慧樹(shù)知到期末考試答案章節(jié)答案2024年哈爾濱工程大學(xué)
- SH/T 3533-2024 石油化工給水排水管道工程施工及驗(yàn)收規(guī)范(正式版)
- 期末考試-公共財(cái)政概論-章節(jié)習(xí)題
- 《飛機(jī)結(jié)構(gòu)與系統(tǒng)》課件-機(jī)翼結(jié)構(gòu)
- 北京市老舊小區(qū)綜合整治改造的思考
- 職業(yè)高中高一上學(xué)期期末數(shù)學(xué)試題卷(含答案)
- (正式版)JBT 3300-2024 平衡重式叉車(chē) 整機(jī)試驗(yàn)方法
評(píng)論
0/150
提交評(píng)論