




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、【精品文檔】如有侵權,請聯(lián)系網站刪除,僅供學習與交流實驗五 數(shù)據(jù)庫綜合查詢(學生).精品文檔.實驗五 數(shù)據(jù)庫綜合查詢一、實驗目的1. 掌握SELECT語句的基本語法和查詢條件表示方法;2. 掌握查詢條件種類和表示方法;3. 掌握連接查詢的表示及使用;4. 掌握嵌套查詢的表示及使用;5. 了解集合查詢的表示及使用。二、實驗內容1. 了解SELECT語句的基本語法格式和執(zhí)行方法;2. 以數(shù)據(jù)庫原理實驗5數(shù)據(jù)為基礎,請使用T-SQL 語句實現(xiàn)進行相應操作;3. 完成實驗報告。三、實驗步驟1. 查詢以數(shù)據(jù)_開頭,且倒數(shù)第3個字符為結的課程的詳細情況 select*from coursewhere Cn
2、ame like '數(shù)據(jù)_%結_'escape''2. 查詢名字中第2個字為陽的學生姓名和學號及選修的課程號、課程名; select sname 姓名,student.sno 學號,o 課程號,ame 課程名from student,course,sc where student.sno=sc.sno and o=o and sname like'_陽%'3. 列出選修了數(shù)學或者大學英語的學生學號、姓名、所在院系、選修課程號及成績; select student.sno,sname,sdept,cno,gradefrom student,scwh
3、ere student.sno=sc.sno and cno IN(select cno from course where cname='數(shù)學'OR CNAME='大學英語')4. 查詢缺少成績的所有學生的詳細情況; select*from student where not exists(select*from sc where sno=student.sno and grade is not null)select*from student where sno in(select sno from sc where grade is null)5. 查詢與
4、張力(假設姓名唯一)年齡不同的所有學生的信息; select b.*from student a,student b where a.sname='張力'and a.sage<>b.sage6. 查詢所選課程的平均成績大于張力的平均成績的學生學號、姓名及平均成績; select student.sno,sname,平均成績=avg(grade)from student,sc where sc.sno=student.sno group by student.sno,sname having avg(grade)>(select avg(grade)from s
5、c where sno=(select sno from student where sname='張力')7. 按照“學號,姓名,所在院系,已修學分”的順序列出學生學分的獲得情況。其中已修學分為考試已經及格的課程學分之和; select student.sno 學號,sname 姓名,sdept 院系,已修學分=sum(credit)from student,course,sc where student.sno=sc.sno and o=o and grade>=60 group by student.sno,sname,sdept8. 列出只選修一門課程的學生的學號
6、、姓名、院系及成績; select student.sno 學號,sname 姓名,sdept 院系,gradefrom student,sc where student.sno=sc.sno and sc.sno in(select sno from sc group by sno having count(cno)=1)9. 查找選修了至少一門和張力選修課程一樣的學生的學號、姓名及課程號; select distinct student.*from student where sno in(select sno from sc where cno in(select cno from co
7、urse where cname='數(shù)據(jù)庫'or cname='數(shù)據(jù)結構')10. 只選修“數(shù)據(jù)庫”和“數(shù)據(jù)結構”兩門課程的學生的基本信息; select o,ame,x.sno,x.sname,grade from student x,sc y,course z where x.sno=y.sno and o=o11. 至少選修“數(shù)據(jù)庫”或“數(shù)據(jù)結構”課程的學生的基本信息;select *from student,sc,coursewhere student.sno=sc.snoand o=oand cname='數(shù)據(jù)庫'orcname=
8、9;數(shù)據(jù)結構'12. 列出所有課程被選修的詳細情況,包括課程號、課程名、學號、姓名及成績; select o,ame,student.sno,student.sname,gradefrom student,sc,coursewhere student.sno=oand o=o13. 查詢只被一名學生選修的課程的課程號、課程名; select cno,cnamefrom coursewhere cno in(select cnofrom scgroup by cnohaving count(sno)=1)14. 使用嵌套查詢列出選修了“數(shù)據(jù)結構”課程的學生學號和姓名; select sn
9、o,snamefrom studentwhere sno in(select snofrom scwhere cno in(select cnofrom coursewhere cname='數(shù)據(jù)結構')15. 使用嵌套查詢查詢其它系中年齡小于CS系的某個學生的學生姓名、年齡和院系; select sname,sage,sdeptfrom studentwhere sage<(select max(sage)from studentwhere sdept='cs'and sdept<>'cs')16. 使用ANY、ALL 查詢,
10、列出其他院系中比CS系所有學生年齡小的學生; select sname,sagefrom studentwhere sage<any(select min(sage)from studentwhere sdept='cs'and sdept<>'cs')select sname,sagefrom studentwhere sage<all(select sagefrom studentwhere sdept='cs'and sdept<>'cs')17. 分別使用連接查詢和嵌套查詢,列出與張力在一個院系的學生的信息; select*from studentwhere sdept=(select sdeptfrom studentwhere sname='張力')18. 使用集合查詢列出CS系的學生以及性別為女的學生名單; select snamefrom studentwhere sdept='cs'unionselect snamefrom studentwhere ssex='女'19. 使用集合查詢列出CS系的學生與年齡不大于19歲的學生的交集、差集; select*from studentwhere sdept='cs
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國三輪車機械減震器行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國PVC塑料波浪瓦行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國PET綠色膠帶行業(yè)投資前景及策略咨詢報告
- 2025至2030年中國5頭玫瑰花人造花行業(yè)投資前景及策略咨詢報告
- 家長會課件背景圖片
- 2025年中國蛋糕柜市場調查研究報告
- 小學生感恩節(jié)主題課件
- 2025年鄉(xiāng)鎮(zhèn)污水處理廠承包合同
- 小學生感恩父母班會課件
- 2025合同的履行原則:貨物采購合同的履行與管理
- 2025年中考英語沖刺仿真模擬測試卷(含答案)
- 2025國家開放大學《商務英語1》綜合測試形考任務答案
- 浪潮軟件開發(fā)面試題目及答案
- 《天然植物化學成分與抗腫瘤機制》課件
- 2025年全國保密教育考試試卷附答案(三套)
- 股權代簽協(xié)議書范本
- 校辦文員筆試題目及答案
- 生物安全柜試題及答案
- 2025年大學英語四級考試試題及答案解析
- 2025年安全生產月主題培訓課件
- 2024北京朝陽區(qū)四年級(下)期末語文試題及答案
評論
0/150
提交評論