



免費預覽已結束,剩余1頁可下載查看
下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
試驗七 Sql 查詢語句目的: 掌握 Select 查詢語句。一 單表1查詢年齡在19至21歲之間的女生的學號,姓名,年齡,按年齡從大到小排列。select sno,sname,sage from studentwhere sage between 19 and 21 and ssex=女 order by sage desc2查詢姓名中第戎2個字為“明”字的學生學號、性別。select sname ,ssex from student where sname like _明%3查詢 1001課程沒有成績的學生學號、課程號select sno,cno from sc where grade is null and cno=10014查詢JSJ 、SX、WL 系的學生學號,姓名,結果按系及學號排列select sno,sname from student where sdept in (JSJ,SX,WL)order by sdept,sno5按10分制查詢學生的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 表中的學生共分布在那幾個系中。(distinct)select distinct sdept from student7查詢0001號學生1001,1002課程的成績。 Select cno from sc where sno=0001 and (cno=1001 or cno=1002)二 統計1查詢姓名中有“明”字的學生人數。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分的學生學號及平均分select sc.sno , avg(grade) from scgroup by sc.snohaving avg(grade)806 統計選修課程超過 2 門的學生學號 select sno from sc group by sno having count(*)27 統計有10位成績大于85分以上的課程號。Select cno from scwhere grade85group by cno having count(*) =108 統計平均分不及格的學生學號select sno from sc group by sno having avg(grade)609 統計有大于兩門課不及格的學生學號select sno from sc where grade2三 連接1查詢 JSJ 系的學生選修的課程號 select cno from student,sc where student.sno=sc.sno and sdept=JSJ2查詢選修1002 課程的學生的學生姓名 (不用嵌套及嵌套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查詢數據庫原理不及格的學生學號及成績select sno,grade from sc ,coursewhere o=o and cname=數據庫原理4查詢選修“數據庫原理”課且成績 80 以上的學生姓名(不用嵌套及嵌套2種方法)a: select sname from student , sc , course where student.sno=sc.sno and o = o andgrade80 and cname=數據庫原理b: select sname from student where sno in ( select sno from sc where grade80 and cno in ( select cno from course where cname=數據庫原理) )5查詢平均分不及格的學生的學號,姓名,平均分。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查詢男學生學號、姓名、課程號、成績。(一門課程也沒有選修的男學生也要列出,不能遺漏)select student.sno,sname,cno,grade from student left join sc ON student.sno=sc.sno and ssex=男四 嵌套、相關及其他1 查詢平均分不及格的學生人數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課程的學生姓名。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課程第一名的學生學號(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 查詢平均分前三名的學生學號select top 3 sno from sc group by sno order by avg(grade) desc7 查詢 JSJ 系的學生與年齡不大于19歲的學生的差集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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 三年級信息技術上冊 第一單元 第5課《畫美麗的早晨》教學設計2 冀教版
- 加班審批表(完整)
- 會議(培訓)記錄(完整版)
- 九年級美術(浙美版)上冊教學設計
- 2024南方出版傳媒股份有限公司校園招聘筆試參考題庫附帶答案詳解
- 一年級道德與法治下冊 第二單元 這樣做真好 第5課《懂禮貌 人人夸》教學設計 粵教版
- 教師個人師德師風學習培訓心得合集
- 七年級生物下冊 第四單元 第11章 第2節 尿的形成與排出教學設計 (新版)北師大版
- 全國閩教版初中信息技術八年級上冊第一單元活動一《圖像的獲取》教學設計
- 九年級語文上冊 第六單元 22范進中舉教學設計 新人教版
- 2023年孕婦健康管理分析報告
- JJF 2119-2024低氣壓試驗箱校準規范
- 《暢游海底世界-趣味折紙 》(教學設計)-三年級上冊勞動蘇教版
- 外科學進展與發展史
- 【工業送料六軸機械手結構設計9400字(論文)】
- SH/T 3533-2024 石油化工給水排水管道工程施工及驗收規范(正式版)
- 智研咨詢發布《2024年中國新中式服裝行業市場規模分析及發展趨勢預測報告》
- 北京市老舊小區綜合整治改造的思考
- 職業高中高一上學期期末數學試題卷(含答案)
- 電梯維保服務考核標準及評分辦法
- 如何合理控制銷售費用
評論
0/150
提交評論